Switch case MCQ 9 : Multiple Parameters in Case Label

Switch case MCQ 9 : Multiple Parameters in Case Label

Problem Statement 9 :

void main()
{
int choice = 2 ;
switch(choice)
{

case 1,2,1 :
printf("nAllas");
break;

case 1,3,2 :
printf("nBabo");
break;

case 4,5,3 :
printf("nHurray");
break;
}
}
Options : Guess the Output
  1. Babo
  2. Error : Multiple Parameter’s not allowed
  3. Hurray
  4. Allas




How ? Why ?
  1. Multiple Numbers in cases are seperated  by comma
  2. Comma Returns Rightmost number
  3. case 1,2,3 will returns 3
  4. So two cases case 1,2,3 AND case 2,3,3  are two same cases


Select Switch Case Question :

Bookmark & Share