Switch case MCQ 13: Multiple parameters to switch case
Switch case MCQ 13: Multiple parameters to switch case
Problem Statement 13 : Multiple parameters to switch case
void main() { int choice = 1 ; switch(choice,choice+1,choice+2) { case var: printf("\nAllas"); break; case 2: printf("\nBabo"); break; case 3: printf("\nHurray"); break; } }
Options : Guess the Output
- Babo
- Error : Variables are not allowed
- Hurray
- Allas
Output :
Hurray
Explanation
- Comma Returns Rightmost number
- Switch case contain 3 parameter
- Rightmost variable is ‘choice+2’ so it returns ‘choice+2’
- Value of choice = 1 So “Choice+2 = 3”
- Case 3 will be executed