control structure: if else ladder and switch case
#include<iostream>
using namespace std;
int main() {
// selection control structure: if else-if... else ladder
int age;
cout << "Tell me your age" << endl;
cin >> age;
// if ((age < 18) && (age>0)) {
// cout << "You are a child and you cannot come to my party" << endl;
// }
// else if (age == 18) {
// cout << "You are a kid and you will get a kid pass to my party" << endl;
// }
// else if (age<1) {
// cout<<"you are not yet born";
// }
// else if (age>100) {
// cout<<"you are too old to come to the party";
// }
// else {
// cout << "You are an adult and you can come to my party" << endl;
// }
// selectrion control structure: switch case statements
switch (age) {
case 18:
cout<<"you are 18"<<endl;
break;
case 19:
cout<<"you are 19"<<endl;
break;
case 20:
cout<<"you are 20"<<endl;
break;
default:
cout<<"no special cases"<<endl;
}
cout<<"done with switch case"<<endl;
//hum break nhi lgaenge to uss case se lekr saare cases print hojaenge
//break mtlb vo kud jata seedha neeche
return 0;
}
Comments
Post a Comment