-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path03_switch_case.c
61 lines (57 loc) · 1.08 KB
/
03_switch_case.c
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
53
54
55
56
57
58
59
60
61
//#include<stdio.h>
//
//int main(){
// int rating;
// printf("Enter your rating (1-5): \n");
// scanf("%d", &rating);
// switch(rating){
// case 1:
// printf("Your rating is 1\n");
// break;
// case 2:
// printf("Your rating is 2\n");
// break;
// case 3:
// printf("Your rating is 3\n");
// break;
// case 4:
// printf("Your rating is 4\n");
// break;
// case 5:
// printf("Your rating is 5\n");
// break;
// default :
// printf("Invalid rating!\n");
// break;
// }
//
// return 0;
//}
#include<stdio.h>
int main()
{
int n;
printf("enter a rating between 1-5: \n");
scanf("%d", &n);
switch(n){
case 1:
printf("your rating is 1");
break;
case 2:
printf("your rating is 2");
break;
case 3:
printf("your rating is 3");
break;
case 4:
printf("your rating is 4");
break;
case 5:
printf("your rating is 5");
break;
default:
printf("invalid rating");
break;
return 0;
}
}