PROGRAM TO CALCULATE GRADE OF A STUDENT

/*PROGRAM TO CALCULATE GRADE OF A STUDENT*/
#include<stdio.h>
#include<conio.h>
void main()
{
int max,t=0;
float a,b,c,sum=0,per=0;
clrscr();
printf(“Enter the maximum marks for each subject: “);
scanf(“%d”,&max);
printf(“Enter the marks obtained by the student in each subject: “);
scanf(“%f%f%f”,&a,&b,&c);
if((a>max)||(b>max)||(c>max))
printf(“\n\t!!Wrong data !!\nThe obtained marks should not exceed the maximum marks.”);
else
{
t=max*3;
sum=a+b+c;
per=(sum/t)*100;
printf(“\n\t******RESULT******\n”);
printf(“\nMaximum marks : %d\n”,t);
printf(“Obtained marks: %f\n”,sum);
printf(“Percentage    : %f\n”,per);
if(per>=80)
printf(“Grade         : A\n”);
else if((per>=60)&&(per<80))
printf(“Grade         : B\n”);
else if((per>=40)&&(per<60))
printf(“Grade         : C\n”);
else
printf(“Result        : Fail\n”);
}
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *