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 <iostream>
#include <conio.h>

using namespace std;

int main()
{
    int e;
    cout<<"Enter marks obtained in English subject ";
    cin>>e;

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

Output

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