Home » CPP Programming Examples For Practice » CPP Programs » The marks obtained by a student in 5 different subjects are input by the user. The student gets a division as per the following rules: Percentage above or equal to 60 - First division Percentage between 50 and 59 - Second division Percentage between 40 and 49 - Third division Percentage less than 40 - Fail Write a program to calculate the division obtained by the student.
#include<iostream>usingnamespacestd;intmain(){intsub1,sub2,sub3,sub4,sub5,percentage;cout<<"Enter marks of five subjects : ";cin>>sub1>>sub2>>sub3>>sub4>>sub5;percentage=(sub1+sub2+sub3+sub4+sub5)/5;if(percentage>=60)cout<<"Ist division";elseif(percentage>=50)cout<<"IInd division";elseif(percentage>=40)cout<<"IIIrd division";elsecout<<"Fail";return0;}
The Output Is:
SAMPLE RUN # 1
Enter marks of five subjects : 34 54 67 78 45
II division
SAMPLE RUN # 2
Enter marks of five subjects : 76 64 67 78 53
I division
SAMPLE RUN # 3
Enter marks of five subjects : 34 44 57 38 42
III division
SAMPLE RUN # 4
Enter marks of five subjects : 14 15 26 38 34
Fail
Post a Comment