The marks obtained by a student in different subjects are input by the user.The student gets as per the following rules;
>=70% grade A
Between 60 and 70% grade B
Between 50 and 60% grade C
Between 40 and 50% grade D
Below 40% grade E
Write a c++ program to compute and display the grade obtained by a student whenever the user enters the marks
#include<iostream>
using namespace std;
char grade(int mark){
if(mark>=70){
return 'A';
}
else if(mark >=60 && mark<70){
return 'B';
}
else if(mark >=50 && mark<60){
return 'C';
}
else if(mark >=40 && mark<50){
return 'D';
}
else if(mark <40){
return 'E';
}
}
int main(){
int mark;
char c;
do{
cout<<"Enter mark \t "<<endl;
cin>>mark;
cout<<"The grade is: "<<grade(mark)<<endl;
cout<<"Enter y to continue entering marks or n to exit the program\n";
cin>>c;
}while(c!= 'n' );
}
Comments
Leave a comment