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...
Write a Java program that asks the user to enter a person’s age. Then the program...
Write a Java program that asks the user to enter a person’s age. Then the program should display text indicating whether the person is an infant, a toddler, a child, a teenager, an adult, or a senior. It should display it just like this: “This person’s age category: x”, where x is the person’s age category based on the following guidelines: If less than 1 year old, the person is an infant. If at least 1 year old but younger...
(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.
Write a C++ program that asks the user to enter in three numbers and displays the...
Write a C++ program that asks the user to enter in three numbers and displays the numbers in ascending order. If the three numbers are all the same the program should tell the user that all the numbers are equal and exits the program. Be sure to think about all the possible cases of three numbers. Be sure to test all possible paths. Sample Runs: NOTE: not all possible runs are shown below. Sample Run 1 Welcome to the order...
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
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    } }
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....
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.
6.         Write a single statement that prompts the user to enter their age in years and places...
6.         Write a single statement that prompts the user to enter their age in years and places the integer value in a variable named age. 7.         Can a program place more than one statement on the same program line? 8.         Write a short code segment in Python that prompts the user to enter the number of quarters, dimes, nickels and pennies they have, compute the total value and print that value.
(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.