if,,,else or switch case,,,depends on question
If else statement
#include
main ()
{
declare variable
int age;
//input
cout<<"enter your age =";
cin>>age;
//if..else statements
{ cout <<"your are child !";}
else if (age > = 7 ll age < = 12)
{ cout <<"you are teenager !";}
else if (age > = 22 ll age < = 30)
{cout <<"you are adult now!!";}
else if (age >30)
{ cout <<"you are old booooo.....";}
else
{cout<<"invalid selection";}
return o;
}
SWITCH CASE
#include
main ()
{
declare variable
int age;
//input
cout<<"enter your age =";
cin>>age;
switch..case statements
switch (age)
{ case ('age'> =1 ll age <= 6):cout<<"you are kids!";break;
case ('age'>=13 ll 'age' <= 12):cout<<"you are adult!";break;
case ('age'>=13 ll 'age'<=21):cout<<"you are teenager!";break;
case ('age'>= 22: ll 'age' <=30):cout<<"you are adult now!!";break;
case ('age'>=30):cout<<"you are old booooo.....";break;
default: cout<<"invalid selection";
}
return 0;
}
0 comments:
Post a Comment
thanks for comment..