Switch case 5 : Multiple Choice Questions in C Programming

Problem Statement 5 : Variables in case labels

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

case 1 :
printf("nSachin Tendulkar is better than any other Cricketer in the World");
break;

case Num :
printf("nI think , Variable is not allowed in Case");
break;

case 7-8+3 :
printf("nWhat do you Think ?");
break;
}
}
Options : Guess the Output
  1. Error
  2. I think , Variable is not allowed in Case
  3. What do you Think ?
  4. Sachin Tendulkar is better than any other Cricketer in the World



Why ? Explanation  :
  1. Variables in switch case , not allowed
  2. Variable in above program is : Num
  3. To have Constant Expression , Switch Label Should not contain Variable
  4. For more details ……

Select Switch Case Question :


Bookmark & Share