Hi there just having a little trouble getting this switch statement to work. Im using bloodshed c++ and tried to compile the following:
The errors im getting is:
cpp:20: error: case label `'A'' not within a switch statement
cpp:22: error: break statement not within loop or switch
cpp:24: error: case label `'B'' not within a switch statement
cpp:26: error: break statement not within loop or switch
cpp:28: error: case label `'C'' not within a switch statement
cpp:30: error: break statement not within loop or switch
cpp:32: error: case label `'D'' not within a switch statement
cpp:34: error: break statement not within loop or switch
// Pg 164 Ex 4.4 Qu 1.
#include <iostream>
usingnamespace std;
int main ()
{
char letGrad, ch;
cout << "Please enter a character: ";
cin >> letGrad;
switch (letGrad);
{
case'A':
cout << "The numerical grade is between 90 and 100";
break;
case'B':
cout << "The numerical grade is between 80 and 89.9";
break;
case'C':
cout << "The numerical grade is between 70 and 79.9";
break;
case'D':
cout << "How are you going to explain this one?";
break;
}
cout << "Of course I had nothing to do with the grade.";
cout << "\nThe professor was really off the wall.";
system ("pause");
return 0;
}