Given marks in three subjects (English, Mathematics and Science) out of 100 of a student the task is to calculate the average marks and grade according to the specifications. Also accept name and class of the student from the user.
- Average 90 up — Grade A
- Average 80-89 — Grade B
- Average 70-79 — Grade C
- Average 60-69 — Grade D
- Average 50-59 — Grade E
- Average 50 below — Grade F
C
#include <stdio.h>
int main ()
{
int c=0, eng=0, math=0, sci=0;
double avg=0.0;
char name[100];
printf("Enter your name: ");
scanf("%s",&name);
printf("Class: ");
scanf("%d",&c);
printf("Marks in English: ");
scanf("%d",&eng);
printf("Marks in Mathematics: ");
scanf("%d",&math);
printf("Marks in Science: ");
scanf("%d",&sci);
avg=(eng+math+sci)/3;
if(avg>=90)
{
printf("GRADE: A");
}
else if(avg>=80&&avg<90)
{
printf("GRADE: B");
}
else if(avg>=70&&avg<80)
{
printf("GRADE: C");
}
else if(avg>=60&&avg<70)
{
printf("GRADE: D");
}
else if(avg>=50&&avg<60)
{
printf("GRADE: E");
}
else
{
printf("GRADE: F");
}
return 0;
}C