## C Programming

### Calculate grade of a student

#### Objective:

Enter 3 subject marks of a student, calculate the percentage, and find the grade as per the following rules. It is assumed that the maximum marks of each subject are 100.

- If percentage
**>= 85**, then the grade will be**S** - If the percentage is between
**75-84.99**, then the grade will be**A** - If the percentage is between
**65-74.99**, then the grade will be**B** - If the percentage is between
**55-64.99**, then the grade will be**C** - If the percentage is between
**50-54.99**, then the grade will be**D** - If the percentage is
**<50**, then the grade will be**F**

#### Program / Solution:

#includestdio.h int main() { int m1,m2,m3; float per; char gd; printf("Enter 3 subject marks: "); scanf("%d %d %d",&m1,&m2,&m3); per = (m1 + m2 + m3)/3.0f; if(per >= 85) { gd = 'S'; } else if(per >= 75) { gd = 'A'; } else if(per >= 65) { gd = 'B'; } else if(per >= 55) { gd = 'C'; } else if(per >= 50) { gd = 'D'; } else { gd = 'F'; } printf("Percentage = %.2f\nGrade = %c",per,gd); return 0; }

#### Sample Output:

Enter 3 subject marks: 85 74 68 Percentage = 75.67 Grade = A