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
- Babo
- Error : Variables are not allowed
- Hurray
- Allas
How ? Why ?
- Const is only to declare constant variable
- Const is allowed in switch
Select Switch Case Question :