Final Answer:
The default label must be the last label in the switch statement, s wrong with following code
Therefore, correct answer is (d) The default label must be the last label in the switch statement.
Step-by-step explanation:
The issue with the given code lies in the placement of the default label. According to C/C++ syntax rules for a switch statement, the default label must be the last label in the switch block. In the provided code, the default label appears before the case label 4, which is not allowed.
The corrected version of the code should have the default label placed at the end, after all the case labels, including case 4.
Corrected code snippet:
void test(int x)
{
switch (x)
{
case 1:
case 2:
case 0:
case 4:
break;
default:
break;
}
}
Therefore, correct answer is (d) The default label must be the last label in the switch statement.