#include
main()
{
//declare variable
int age;
//input
cout<<"Enter your age=";
cin>>age;
//if...else statement
if(age>=1||age<=6)
{cout<<"you are kids !!";}
else if(age>=7||age<=12)
{cout<<"you are child !!";}
else if(age>=13||age<=21)
{cout<<"you are teenager !!";}
else if(age>=22||age<=30)
{cout<<"you are adult !!";}
else if(age>30)
{cout<<"you are old !!";}
else
{cout<<"Invalid selection";}
return 0;
}
SWITCH.....CASE STATEMENT
#include
main()
{
//declare variable
int age;
//input
cout<<"Enter your age=";
cin>>age;
//switch...case statement
switch(age)
{
case(age>=1||age<=6):cout<<"you are kids !!";break;
case(age>=7||age<=12):cout<<"you are kids !!";break;
case(age>=13||age<=21):cout<<"you are kids !!";break;
case(age>=22||age<=30):cout<<"you are kids !!";break;
case(age>30):cout<<"you are kids !!";break;
default:cout<<"Invalid selection";
}
return 0;
}
No comments:
Post a Comment