Monday, 8 December 2014

Program to find the grade of student
#include<stdio.h>
#include<stdlib.h>
main()
{
int m1,m2,m3,m4,total;
float avg;
char grade;
printf("enter marks in four subjects\n");
scanf("%d%d%d%d",&m1,&m2,&m3,&m4);
total=(m1+m2+m3+m4);
avg=total/4;
printf("total and average marks are %d\t%f\n",total,avg);
if(avg>=85)
grade='A';
else if(avg>=70)
grade='B';
else if(avg>=60)
grade='C';
else if(avg>=50)
grade='D';
else
grade='E';
printf("grade is %c\n",grade);
}
OutPut:
madan@madan-Lenovo-G570:~/madan$ cc ex42.c
madan@madan-Lenovo-G570:~/madan$ ./a.out
enter marks in four subjects
43
54
65
76
total and average marks are 238 59.000000
grade is D