# C Program to Calculate Grade of Student

## Calculate Grade of Student Program in C

Write a C program to calculate grade of student, If percentage > 85 print A grade, If percentage <85 print B grade, If percentage <75 print C grade, If percentage <50 print D grade, If percentage <30 print fail."

• First received marks of each subject.
• Calculate sum of all subjects marks.
• divide total marks by number of subject (percentage=total marks / number of subject).
• If percentage > 85 print A grade, If percentage < 85 && percentage >= 75 print B grade, If percentage < 75 && percentage >= 50 print C grade, If percentage > 30 && percentage <= 50 print D grade, If percentage <30 print fail
• Finally print percentage on screen.

## Program to calculate grade of student

```#include<stdio.h>
#include<conio.h>

void main()
{
int no, i;
float marks[10], per=0, total=0;
clrscr();
printf("Enter number of subject: ");
scanf("%d",&no);
printf("Enter marks of %d subject: ",no);
for(i=0; i<no; i++)
{
scanf("%f",&marks[i]);
}
for(i=0; i<no; i++)
{
total=total+marks[i];
}
per=total/no;
printf("Percentage: %f % \n",per);
if(per>85) {
}
else if(per<85 && per>=75)
{
}
else if(per<75 && per>=50)
{
}
else if(per<50 && per>=30)
{
}
else
{
printf("Fail");
}
getch();
}
```

## Output

```Enter number of subject: 5
Enter marks of 5 subject:
90
50
70
60
80
Percentage: 70.00 %
```

## Program to calculate grade of student

```#include<stdio.h>
#include<conio.h>

void main()
{
int no, i;
float marks[10], per=0, total=0;
clrscr();
printf("Enter number of subject: ");
scanf("%d",&no);
printf("Enter marks of %d subject: ",no);
for(i=0; i<no; i++)
{
scanf("%f",&marks[i]);
}
for(i=0; i<no; i++)
{
total=total+marks[i];
}
per=total/no;
printf("Percentage: %f % \n",per);
if(per>85)
{
}
else if(per<85 && per>=75)
{
}
else if(per<75 && per>=50)
{
}
else if(per<50 && per>=30)
{
}
else
{
}
getch();
}
```

## Output

```Enter number of subject: 5
Enter marks of 5 subject:
90
50
70
60
80
Percentage: 70.00 %
```