Answer:
#include <iostream>
#include <cstdlib>
using namespace std;
char grade(double marks){
if(marks>=90)
{
return 'A';
}
else if (marks >=80 && marks<90)
{
return 'B';
}
else if (marks >=70 && marks<80)
{
return 'C';
}
else if (marks >=60 && marks<70)
{
return 'D';
}
else if ( marks<60)
{
return 'F';
}
}
int main()
{
double marks;
cout <<"Ener marks";
cin >>marks;
char grd=grade(marks);
cout<<"Grae is "<<grd;
return 0;
}
Explanation:
Take input from user for grades in double type variable. Write function grade that takes a parameter of type double as input. Inside grade function write if statements defining ranges for the grades. Which if statement s true for given marks it returns grade value.
In main declare a variable grd and store function returned value in it.