C Program to Display the Average Marks and Grade of Student

In this program, the user is ask to enter the marks of 5 subjects. Then the total marks is calculated. Finally the user will get the percentage and the grade.



Source Code
#include<stdio.h>

int main()
{
    int m1, m2, m3, m4, m5, total;
    float per;
    printf("Enter marks of five subjects: ");
    scanf("%d%d%d%d%d", &m1, &m2, &m3, &m4, &m5);

    total = m1 + m2 + m3 + m4 + m5;
    printf("\nTotal marks = %d", total);

    per = total / 5;
    printf("\nPercentage = %0.2f", per);

    if(per >=75)
        printf("\nCongratulations, you got DISTINCTION.");
    else if(per >= 60)
        printf("\nYou got FIRST CLASS.");
    else if(per >= 50)
        printf("\nYou got SECOND CLASS.");
    else if(per >= 40)
        printf("\nYou are PASSED.");
    else
        printf("You are FAILED.");
    return 0;
}
Output
Enter marks of five subjects:
75
54
68
61
84

Total marks = 342
Percentage = 68.00
You got FIRST CLASS.





"Coding Hub - Learn to code" app now available on Google Play Store