C++ Program to Calculate Grade of Student:

C++ Program to Find Grade of Student:

C++ programs:

Calculate Grade of Student:

C++ Program to Calculate Grade of Student  C++ Program to Find Grade of Student


Source code:

// C++ Program to Find Grade of Student
#include<iostream>
/*  iostream provides basic
input and output services for C++ programs */
using namespace std;
int main()
// Th execution of program start with the main function 
{
int i;
//Variable Declarations specify the type followed by the name
//Initialization is the process of assign the value to a variable
    float mark, sum=0, avg;
    cout<<"Enter Marks obtained in 5 Subjects: ";
// cout is used to display the same statement in the output.
    for(i=0; i<5; i++)// For Loop
    {
        cin>>mark;
        sum = sum+mark;
    }
    avg = sum/5;
    cout<<"\nGrade = ";
    if(avg>=91 && avg<=100)
/* if else statement Use if to specify
a block of code to be executed,
if a specified condition is true. */
        cout<<"A+";
    else if(avg>=81 && avg<91)
/* Use else if to specify a new condition to test,
if the first condition is false.*/
        cout<<"A";
    else if(avg>=71 && avg<81)
        cout<<"B+";
    else if(avg>=61 && avg<71)
        cout<<"B";
    else if(avg>=51 && avg<61)
        cout<<"C+";
    else if(avg>=41 && avg<51)
        cout<<"C";
    else if(avg>=33 && avg<41)
        cout<<"D";
    else if(avg>=21 && avg<33)
        cout<<"E+";
    else if(avg>=0 && avg<21)
        cout<<"E";
    else 
/* Use else to specify a block of code to be executed,
if the same condition is false.*/
        cout<<"Invalid!";
    cout<<endl;
    return 0;
}