Switch case MCQ 16: Constant Expressions are allowed
Switch case MCQ 16: Constant Expressions are allowed
Problem Statement 16 : Constant Expressions are allowed
void main() { int choice = 2 ; switch(choice) { case 1+2/3: printf("\nCase 1"); break; case 2/2*3: printf("\nCase 3"); break; } }
Options : Does Expressions are allowed in Case Labels
- Yes
- No
[toggle title=”Output”]Yes[/toggle]
How and Why ?
- Generally Case Label Should be Integer / Constant
- As Constant Expression in Case Labels Results in Constant Value .
- Thus above code is absolutely Correct .