In this program, the user is ask to enter the marks of 5 subjects. Then the total marks is calculated. Finally the user will get the percentage and the grade.
#include<iostream>
using namespace std;
int main()
{
int m1, m2, m3, m4, m5, total;
float per;
cout<<"Enter marks of five subjects: ";
cin>> m1 >> m2 >> m3 >> m4 >> m5;
total = m1 + m2 + m3 + m4 + m5;
cout<<"\nTotal marks = " << total;
per = (float) total / 5;
cout<<"\nPercentage = " << per;
if(per >=75)
cout<<"\nCongratulations, you got DISTINCTION.";
else if(per >= 60)
cout<<"\nYou got FIRST CLASS.";
else if(per >= 50)
cout<<"\nYou got SECOND CLASS.";
else if(per >= 40)
cout<<"\nYou are PASSED.";
else
cout<<"You are FAILED.";
return 0;
}
Enter marks of five subjects:
75
54
68
61
84
Total marks = 342
Percentage = 68.4
You got FIRST CLASS.