Question

Write a program that checks the age of a user (C++ Programming)    If the user...

Write a program that checks the age of a user (C++ Programming)   

  1. If the user is 18 to 20 print “Sing a song”
  2. If the user is younger than 18 then print “Please show a dance step”
  3. Else Welcome the user and print “You are audience”

Homework Answers

Answer #1

// Required C++ code:

#include <bits/stdc++.h>
using namespace std;
int main(){
   int age; // declaring variable
   cout<<"Please Enter your age: ";
   cin>>age; //reading user input of age

   if(age>=18 && age<=20){ //checking if age is between 18 to 20
       cout<<"Sing a song";
   }else if(age<18){        //checking if age less than 18
       cout<<"Please show a dance step";
   }else{
       cout<<"You are audience"; //printing required statement
   }

   return 0;
}

OUTPUT:

Hope this helped. Please do upvote and if there are any queries please ask in the comments section.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write the following program using the if/else decision structure using C programming. This problem calculates the...
Write the following program using the if/else decision structure using C programming. This problem calculates the cost of a movie ticket. If a person is 5 years old or younger, the movie ticket is free. If the person is over 65, then the movie ticket costs $5.00. Everyone else pays $10.00. Your program should ask for the person’s age. It should also print output which looks like this: You are (put their age her) year old, so your movie ticket...
(C PROGRAMMING) Please use arrays// Create a program that presents a menu to the user to:...
(C PROGRAMMING) Please use arrays// Create a program that presents a menu to the user to: 1) enter data 2) print data 3) clear data 0) exit. Please complete option 3.
in c++ Write a C++ program that asks the user to enter an integer number and...
in c++ Write a C++ program that asks the user to enter an integer number and prints it back "vertically" to the screen. Use recursion in your solution. As an example of how the program will work: Please enter an integer: 12345 The integer you entered will print vertically as: 1 2 3 4 5
1)Write a program that asks a user for a number. If (and only if) the number...
1)Write a program that asks a user for a number. If (and only if) the number is greater than zero print “The number is valid” 2)Write a program that asks a user for a grade. If (and only if) the grade is greater than zero and less than 101, print “The grade is valid” 3)Write a program that asks a user how many widgets they want to buy and prints out what the user should pay. Widgets costs 10 dollars....
C# Programming Write, compile, and test a program named Lyrics that displays at least four lines...
C# Programming Write, compile, and test a program named Lyrics that displays at least four lines of your favorite song. Code Patterns to follow are the following (All these have to check out: -Checks for correct use of WriteLine (4x) Description Searched your code for a specific pattern: (\s*WriteLine\(".*"\);\s*){4,} Start code with this outline: using static System.Console; class Lyrics {    static void Main()    {     // Write your main here    } }
in C++ Write a program to use the IF ELSE statement in the following way. Have...
in C++ Write a program to use the IF ELSE statement in the following way. Have the user input a value, x If the value is less than 100, present, "you got 5% interest" and display on the screen the total of the X*1.05 Else print on the screen, "you got 10% interest", and display the value X*1.10.
(Python Programming) Write a program that prompts a user for a positive integer and then uses...
(Python Programming) Write a program that prompts a user for a positive integer and then uses a loop to calculate and display the sum of specific fractions as follows: Let's say the user enters 5, then your program will compute: 1/5 + 2/4 + 3/3 + 4/2 + 5/1 which is 8.7.
write a program that asks the User to enter a letter, then asks the user to...
write a program that asks the User to enter a letter, then asks the user to enter a sentence. the program will then print out how many time that letter occurred in the sentence. in C Language
Problems . Using the if...else if...else if......else, write a C++ program that - Asks the user...
Problems . Using the if...else if...else if......else, write a C++ program that - Asks the user to input two integers. - If both of them are greater than zero, then output their sum. - If only one integer is greater than zero, then output their difference. - Otherwise, output a message "your two number <0".
Write a c++ program to pull a random number between 1-100 inclusive. Ask the user to...
Write a c++ program to pull a random number between 1-100 inclusive. Ask the user to guess the number. If the random number is higher than the guess, print "Higher". If the random number is less than the guess, print "Lower". If the random number is equal to the quess, print "Correct!". Create a variable to count the number of guesses and intitialize it to zero. int guesses=0; Increase this variable by 1 every time the user enters a new...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT