Determine whether the following are valid switch statements. If not,
explain why. Assume that n and digit are int variables. (11)
a. switch (n <5 2)
{
case 0:
cout << "Draw." << endl;
break;
case 1:
cout << "Win." << endl;
break;
case 2:
cout << "Lose." << endl;
break;
}
The above is not a valid switch statement. The cases should have a Boolean values.
Comments
Leave a comment