Dremendo Tag Line

Input mark and print grade in C

if else if - Question 10

In this question, we will see how to input mark obtained in English subject in an examination and print the grades accordingly in C programming using the if else if statement. To know more about if else if statement click on the if else if statement lesson.

Q10) Write a program in C to input mark obtained in English subject in an examination and print the grades accordingly.

Marks in English Grade
90 or above A
70 to 89 B
50 to 69 C
40 to 49 D
Below 40 F

Program

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

int main()
{
    int e;
    printf("Enter marks obtained in English subject ");
    scanf("%d",&e);

    if(e>=90)
    {
        printf("Grade = A");
    }
    else if(e>=70 && e<=89)
    {
        printf("Grade = B");
    }
    else if(e>=50 && e<=69)
    {
        printf("Grade = C");
    }
    else if(e>=40 && e<=49)
    {
        printf("Grade = D");
    }
    else
    {
        printf("Grade = F");
    }
    return 0;
}

Output

Enter marks obtained in English subject 68
Grade = C
video-poster