Find division secured by student - C++ Program

Q. Write a C++ program to display the grade according to the marks by a student. The marks scored is taken as input and the class is displayed according to the following range:

MarksClass
70-100Distinction
60-69First Class
50-59Second Class
40-49Pass Class
0-39Fail

Answer:

Following program is displaying the grade of a student according to the scored marks.

#include<iostream>
using namespace std;
int main()
{
        int marks;
        cout<<"\n Enter Marks : ";
        cin>>marks;
        if (marks>=70)
        {
                cout<<"\n Distinction";
        }
        else
        {
                if(marks>=60)
                {
                        cout<<"\n First Class";
                }
                else
                {
                        if(marks>=50)
                        {
                                cout<<"\n Second Class";
                        }
                        else
                        {
                                cout<<"\n Fail";
                        }
                }
        }
        return 0;
}


Output:

switch grade