Sunday 15 June 2014

C++ program to calculate Grades



Here is a C++ program to calculate Grades


 SOURCE CODE OUTPUT
#include <iostream>
using namespace std;
int main()
{
    int sub1,sub2,sub3,sub4,sub5,total,percent;
    cout<<"Enter the marks of 5 subjects ";
    cin>>sub1>>sub2>>sub3>>sub4>>sub5;
    total=sub1+sub2+sub3+sub4+sub5;
    percent=total*100/500;
    cout<<"Total Marks : "<<total<<endl;
    cout<<"Grade : ";
    if(percent>=90)
        cout<<"A+";
    else if(percent>=80)
        cout<<"A";
    else if(percent>=70)
        cout<<"B+";
    else if(percent>=60)
        cout<<"B";
    else if(percent>=50)
        cout<<"C+";
    else if(percent>=40)
        cout<<"C";
    else if(percent>=33)
        cout<<"D";
    else
        cout<<"F";
    cout<<endl;
    return 0;
}

Any questions regarding to program please write in comments.

No comments:

Post a Comment