-
Notifications
You must be signed in to change notification settings - Fork 4
/
gradeandaverage.c
42 lines (41 loc) · 937 Bytes
/
gradeandaverage.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
/*
Write a program to enter the marks of 3 subjects, Physics, Chemistry
and Maths. Display the grade of a student as per the following rules,
80 to 100 - Honours
60 to 79 - First class
50 to 59 - Second class
40 to 49 - Third class
0 to 39 - /Fail
*/
#include <stdio.h>
void main()
{
int a, b, c, avg;
printf("Enter the marks of Physics:\n");
scanf("%d", &a);
printf("Enter the marks of Chemistry:\n");
scanf("%d", &b);
printf("Enter the marks of Maths:\n");
scanf("%d", &c);
avg = (a + b + c) / 3;
if (avg >= 80 && avg <= 100)
{
printf("Honours!");
}
else if (avg >= 60 && avg <= 79)
{
printf("First Class!");
}
else if (avg >= 50 && avg <= 59)
{
printf("Second Class!");
}
else if (avg >= 40 && avg <= 49)
{
printf("Third Class!");
}
else
{
printf("Fail!");
}
}