C Program to Calculate Grade of Student

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int mark[5], i;
float sum=0,average;
printf("\n Enter marks obtained in 5 subjects ");
for(i=1; i<=5; i++)
{
printf("\n Subject %d=",i);
scanf("%d",&mark[i]);
sum=sum+mark[i];
}
average=sum/5;
printf("\n Your Grade is ");
if(average>80)
{
printf("A");
}
else if(average>60 && average<=80)
{
printf("B");
}
else if(average>40 && average<=60)
{
printf("C");
}
else
{
printf("D");
}
 getch();
}

Run:




No comments:

Post a Comment

100 C Programs with Code and Output

Program 1: C Program To Read Two Numbers And Print The Sum Of Given Two Numbers. Program 2: C Program To Read Three Numbers And Prin...