-
Notifications
You must be signed in to change notification settings - Fork 0
/
18_SwitchStaemetns.cpp
52 lines (44 loc) · 1.21 KB
/
18_SwitchStaemetns.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
46
47
48
49
50
51
52
// Selection control statement --> Switch statement
#include<iostream>
using namespace std;
int main()
{
char grade;
cout<<"Enter the Grade :==> "<<endl;
cin>>grade;
switch (grade)
{
case 'A':
case 'a': //----> you can check one or more cases for the same block of code
// case 'j':
// case 'k':
// case 'l':
// case 'm':
// case 'e':
cout<<"Great job!"<<endl;
break;
case 'B':
case 'b':
cout<<"Good job!"<<endl;
break;
case 'C':
case 'c':
cout<<"You can do better!"<<endl;
break;
case 'D':
case 'd':
cout<<"You are close to failing !"<<endl;
break;
case 'F':
case 'f':
cout<<"You are failing the course!"<<endl;
break;
default:
cout<<"Ivalid input! please try again..."<<endl;
}
return 0;
}
// Algorithm for this program -->
// 1. Taking the input from the user
// 2. Checking the input from te user by using the switch-case statement
// 3. Printing the output according the cases.