-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathswitch1.c
59 lines (53 loc) · 1.03 KB
/
switch1.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
#include <stdio.h>
#define A_CUTOFF 80
#define B_CUTOFF 70
#define C_CUTOFF 50
#define D_CUTOFF 40
main()
{
char grade;
int marks;
printf("Enter student marks: ");
fflush(stdout);
scanf("%d", &marks);
printf("Marks entered: %d\n", marks);
if (marks >= A_CUTOFF)
{
printf("Entered here at grade A\n");
grade = 'A';
}
else
{
if (marks >= B_CUTOFF)
grade = 'B';
else if (marks >= C_CUTOFF)
grade = 'C';
else if (marks >= D_CUTOFF)
grade = 'D';
else
grade = 'F';
}
printf("Student Grade: %c, ", grade);
fflush(stdout);
switch (grade)
{
case 'A':
printf("Excellent\n");
break;
case 'B':
printf("Good\n");
break;
case 'C':
printf("Average\n");
break;
case 'D':
printf("Poor\n");
break;
case 'F':
printf("Failing\n");
break;
default:
printf("Illegal grade\n");
break;
}
}