Answer to Question #237040 in C++ for c++

Question #237040

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


1
Expert's answer
2021-09-16T13:03:06-0400
#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' );
	
		
	
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS