By 26/03/2014 9 Comments

Exercise # 02 Decision Making Statements in C++

Q: Write a program which gives the following output

Enter age>>

And prints the following:

If Age is greater than 45 then prints the message “You are old stay at home and wait for call”

If Age is greater than 30 and less than 45 then prints “Hey! man enjoy your life with your kids”

If Age is greater than 20 and less than 30 then prints “Cool! have a search for your best suit” 

If Age is greater than 10 and less than 20 then prints “Work hard! Your days to study”

If Age is less than 10 then prints the message ‘Oh! Kid your days to cry”

Use if-else statement.

 

Answer:

#include <iostream.h>
#include <conio.h>

void main()
{
     int UserAge;

     cout<<"Enter the age: ";
     cin>>UserAge;

     if(UserAge>45)
     cout<<"You are old stay at home and wait for call";

     else if(UserAge>30&&UserAge<45)
     cout<<"Hey! man enjoy your life with your kids";

     else if(UserAge>20&&UserAge<30)
     cout<<"Cool! Have a search for your best suit";

     else if(UserAge>10&&UserAge<20)
     cout<<"Work hard! Your days to study";

     else if(UserAge<10)
     cout<<"Oh! Kid your days to cry";

     getch();
}






Posted in: C++ Exercises

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .