Switch case MCQ 12: Const Variables allowed in switch



Switch case MCQ 12: Const Variables allowed in switch

Problem Statement 12 : Const Variables allowed in switch


#include"stdio.h"

void main()
{
int choice = 1 ;
int const var = 2;
switch(choice)
{
case 1:
printf("nAllas");
break;

case var:
printf("nBabo");
break;

case 3:
printf("nHurray");
break;
}
}
Options : Guess the Output
  1. Babo
  2. Error : Variables are not allowed
  3. Hurray
  4. Allas



How ? Why ?

  1. Const is only to declare constant variable
  2. Const is allowed in switch

    Select Switch Case Question :


    Bookmark & Share