BLOGGER TEMPLATES AND TWITTER BACKGROUNDS

Wednesday, March 30, 2011

If Else statement..

If else statement

#include




main()


{


//declare variable


int age;


//if else statement


if(age>=1 ll age<=6)


{cout<<"you are kids!;}


else if(age>=7 ll age<=12)


{cout<<"you are child babe!";}


else if(age>=13 ll age <=21)


{cout<<"you are teenager!";}


else if(age>=21 ll age<=30)


{cout<<"you are adult now!";}


else if(age>=30)


{cout<<"you are old,boo!";}


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 ll 'age'<=6):cout<<"you are kids!";break;


case('age'>=7 ll 'age'<=12):cout<<"you are child beb!";break;


case('age'>=13 ll 'age'<=21):cout<<"you are teenage!";break;


case('age'>=22 ll 'age'<=30):cout<<"you are adult now!";break;


case('age'>=30):cout<<"you are old!";break;


default:cout<<"invalid selection";


}


return 0;


}

0 comments: