I'm currently learning about switches in C++, so I created a grading program that will output a specific message based on the grade entered. Below is the code:
#include <iostream>
using namespace std;
int main()
{
char student_grade;
cout << "Enter student's grade:" << "\n";
cin >> student_grade;
// switch statement for a simple grading system
switch(student_grade)
{
case A:
cout << "You have passed with a distinction!";
break;
case B:
cout << "You have a grade B,congrats.";
break;
case C:
cout << "Average grade,you can do better.";
break;
default:
cout<<"NIL grade";
break;
}
return 0;
}
I get this error once I run it, what did I do wrong?
/root/Desktop/practise.cpp: In function ‘int main()’:
/root/Desktop/practise.cpp:14:6: error: ‘A’ was not declared in this scope
14 | case A:
| ^
/root/Desktop/practise.cpp:17:6: error: ‘B’ was not declared in this scope
17 | case B:
| ^
/root/Desktop/practise.cpp:20:6: error: ‘C’ was not declared in this scope
20 | case C:
| ^