-
Notifications
You must be signed in to change notification settings - Fork 7
/
if_else_switch_case.cpp
45 lines (39 loc) · 976 Bytes
/
if_else_switch_case.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include<iostream>
using namespace std;
int main(){
// cout<<"This is tutorial 9";
int age;
cout<< "Tell me your age"<<endl;
cin>>age;
// 1. Selection control structure: If else-if else ladder
// if((age<18) && (age>0)){
// cout<<"You can not come to my party"<<endl;
// }
// else if(age==18){
// cout<<"You are a kid and you will get a kid pass to the party"<<endl;
// }
// else if(age<1){
// cout<<"You are not yet born"<<endl;
// }
// else{
// cout<<"You can come to the party"<<endl;
// }
// 2. Selection control structure: Switch Case statements
switch (age)
{
case 18:
cout<<"You are 18"<<endl;
break;
case 22:
cout<<"You are 22"<<endl;
break;
case 2:
cout<<"You are 2"<<endl;
break;
default:
cout<<"No special cases"<<endl;
break;
}
cout<<"Done with switch case";
return 0;
}