C++ grading program example – C++ Program to Calculate Grade of Student Using Switch Case

C++ grading program example: In the previous article, we have discussed C++ Program to Find Power of Number using Recursion. In this article, we will see C++ Program to Calculate Grade of Student Using Switch Case. And see Grading System Using Switch Case In C, C Program For Grades Of Student Using Switch, Grading System In C Programming Using Switch, Grading System Using Switch In C++, Grade Program In C Using Switch, Grade System Using Switch Case, Grade Program In C++ Using Switch, Grade Of Student Using Switch In C, Grade Switch Statement C++, Grade Calculator C++, Grade Program In Java Using Switch Case.

C++ Program to Calculate Grade of Student Using Switch Case

C++ grade calculator: In this C++ program, we will calculate the grade of a student based on the total marks obtained by the student in five subjects. Here we will use a switch case statement, however you can write same program using if-else ladder statement also. Here is the range of Grades:
Marks >= 90 : Grade A
Marks >= 70 && < 90 : Grade B
Marks >= 50 && < 70 : Grade C
Marks < 50 : Grade D

We will first ask user to enter the marks of five subjects and calculate the total marks obtained by student. Then we will calculate the average marks by dividing total marks by 5. Now, we will use switch case statement to select the appropriate range for his average marks and print the grade accordingly.

C++ Program to Calculate Grade of Student Using Switch Statement

C++ Program to Calculate Grade of Student Using Switch Statement

// C++ Program to calculate grade of student 
#include <iostream>
using namespace std;
 
int main() {
    int score, i, average;
    float total=0;
  
    cout<< "Enter marks of 5 subjects\n";
  
    for(i=0; i<5; i++) {
 cin >> score;
 total += score;
    }
  
    average = total/5;
  
    cout<<"Grade : ";
    switch(average/10) {
       case 9 :
           cout << "A";
           break;
       case 8 :
       case 7 :
           cout << "B";
           break;
       case 6 :
       case 5 :
           cout << "C";
           break;
       default :
           cout << "D";  
    }
  
    return 0;
}

Output

Enter marks of 5 subjects
97 89 78 87 68
Grade : B

Are you fed up with browsing all concepts related to C++ Programming Programs? Not anymore because all the basic and complex Programs for C++ are covered on our main page just tap on the link available here & save your time to practice more.

Read more: C++ Program to Find Largest Element of an Array

Test yourself:

  1. Find Grade Using Switch Case In C++
  2. Write A C++ Program To Display Grade Of A Student Using Switch Statement
  3. Write A Program To Find Grade Of A Student Given His Marks Using Switch
  4. Write A C Program To Display Grade Of A Student Using Switch Statement
  5. C Program To Find Grade Of A Student Using Switch
  6. C Program To Print Grade Of Student Using Switch Statement
  7. C Program To Find Grade Of A Student Using Switch Case
  8. Java Program To Find Grade Of A Student Using Switch Case
  9. Write A Program To Find The Grade Of Student Using Switch Case
  10. Find Grade Using Switch Case In Java

Related Posts On: