Finding Student Grade in C Program using 3 variables

C Program for finding Student grades, 

Using 3 subjects’ marks out of 100 each student marks will be calculated. If student marks are below 35 in any subjects then He/ She will fail in their exam result output is grade 'F'.

 Total average = (sub1 + sub2 + sub3)/3

 Grading system:- if Percentage is <35 = 'F'

                                                  <50 = 'D'

                                                  <65 = 'C'

                                                  <75 = 'B'

                                                  <90 = 'A'

                                                  <95 = 'A+'

                                                  >95 = 'O' (O - Outstanding)                                  

Here,

    The program is written in a readable format so you can copy it for output in your compiler,


# include<stdio.h>
# include<stdlib.h>
int main()
{
    float physics, math, chemistry,total;
 
    printf("Enter the marks of Physics out of 100:");
    scanf("%f",&physics);
    printf("Enter the marks of Chemistry out of 100:");
    scanf("%f",&chemistry);
    printf("Enter the marks of Maths out of 100:");
    scanf("%f",&math);
 
    total = (math + physics + chemistry)/3;
 
    if(math<0 || physics<0 || chemistry<0 || math>100 || physics>100 || chemistry>100)
        {
            printf("Marks is invalid...!!");
        }
    else if(total<=50 && total>=35 && math>=35 && physics>=35 && chemistry>=35)
        {
            printf("\n Your Grade is D");
        }
    else if(total<=65 && total>50  && math>=35 && physics>=35 && chemistry>=35)
        {
            printf("\n Your Grade is C");
        }
    else if(total<=75 && total>65  && math>=35 && physics>=35 && chemistry>=35)
        {
            printf("\n Your Grade is B");
        }
    else if(total<=90 && total>75  && math>=35 && physics>=35 && chemistry>=35)
        {
            printf("\n Your Grade is A");
        }
    else if(total<=95 && total>90  && math>=35 && physics>=35 && chemistry>=35)
        {
            printf("\n Your Grade is A+");
        }
    else if(total>=95 && total<100  && math>=35 && physics>=35 && chemistry>=35)
        {
            printf("\n Your Grade is O");
        }
    else
        {
            printf("\n Your Grade is F");
        } 
 
    return 0;
}

 

Output 1:-

Output Program

Output 2:-


Output program

Tags