Switch case MCQ 17: Negative Case Labels are allowed
Switch case MCQ 17: Negative Case Labels are allowed
Problem Statement 17 : Negative Case Labels are allowed
void main() { int choice = -2 ; switch(choice) { case -1: printf("\nCase -1"); break; case -2: printf("\nCase -2"); break; } }
Options : Is it necessary to have Case Labels greater than Zero
- Yes
- No
[toggle title=”Output”]No[/toggle]No
How ? Why ?
- Generally Case Label Should be Integer / Constant
- Negative numbers having no decimal point are also considered as Integer
- Thus it is not necessary to have Case Labels greater than Zero