-
Notifications
You must be signed in to change notification settings - Fork 0
/
School grading program
76 lines (63 loc) · 1.36 KB
/
School grading program
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <stdio.h>
/**
* main - solving an assigment
* description - A program for school grading system
* 80 - 100 == A
* 70 - 79 == B
* 65 - 69 == C
* 60 - 64 == D
* 50 - 59 == E
* Below 50 == F
* return 0
*/
int main(void) {
int score;
/* Tell user to type their score */
printf("Enter your score:\n");
/* Accept the user's input */
scanf("%d", &score);
/* check if the score is between 80 and 100, print the
* grade
*/
if (score >= 80 && score <= 100) {
printf("A \n");
if (score >= 95) {
printf("You got Distinction \n");
} else {
printf("You got Excellent \n");
}
}
/* check if the score is between 70 and 79, print the
* grade
*/
else if (score >= 70 && score <= 79) {
printf("B \n");
}
/* check if the score is between 65 and 69, print the
* grad
*/
else if (score >= 65 && score <= 69) {
printf("C \n");
}
/* check if the score is between 60 and 64, print the
* grade
*/
else if (score >= 60 && score <= 64) {
printf("D \n");
}
/* check if the score is between 50 and 59, print the
* grade
*/
else if (score >= 50 && score <= 59)
printf("E \n");
/* check if the score is below 50, print the
* grade
*/
else if (score >= 0 && score <= 50) {
printf("F \n");
}
else {
printf("You entered an invalid score");
}
return 0;
}