-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mark 2.c
36 lines (35 loc) · 887 Bytes
/
Mark 2.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
#include <stdio.h>
char calculateGrade(float marks)
{
if (marks >= 90)
{ return 'A';}
else if (marks >= 80)
{return 'B'; }
else if (marks >= 70)
{ return 'C';}
else if (marks >= 60)
{ return 'D';}
else
{ return 'F';}
}
int main()
{
float subjectMarks[5];
float totalMarks = 0.0;
float averageMarks;
printf("Enter the marks for five subjects (out of 100):\n");
for (int i = 0; i < 5; i++)
{
printf("Subject %d: ", i + 1);
scanf("%f", &subjectMarks[i]);
totalMarks += subjectMarks[i];
}
averageMarks = totalMarks / 5;
printf("\nGrades for each subject:\n");
for (int i = 0; i < 5; i++)
{ printf("Subject %d: %c\n", i + 1, calculateGrade(subjectMarks[i]));
}
printf("\nAverage Marks: %.2f\n", averageMarks);
printf("Grade: %c\n", calculateGrade(averageMarks));
return 0;
}