In this article, you will a c++ program to calculate the student grade. This program asks the user to enter the subject marks the program calculates its grade and displays the result on the screen.
Criteria to calculate student grades.
Criteria Range | Grade |
90-100 | A+ |
80-89 | A |
70-79 | B |
60-69 | C |
50-59 | D |
Below 50 | F |
Example 1: C++ student grade program
//C++ program to calculate student grade
#include <iostream>
using namespace std;
int main(){
int marks;
cout<<"Enter student marks: ";
cin>>marks;
if (marks >= 90 && marks <=100){
cout<<"Your grade is A+";
}
else if (marks >= 80 && marks <=89){
cout<<"Your grade is A";
}
else if (marks >= 70 && marks <= 79){
cout<<"Your grade is B";
}
else if (marks >= 60 && marks <=69){
cout<<"Your grade is C";
}
else if (marks >= 50 && marks <=59){
cout<<"Your grade is D";
}
else if (marks <=50 && marks>=0){
cout<<"Your grade is F";
}
else{
cout<<"Please enter valid marks";
}
return 0;
}