41. What will be the output of following code :
// Assume all header files are included
#include<stdio.h>
main()
{
int i=1,j=2;
switch(i)
{
case 1: printf("GOOD");
break;
case j: printf("BAD");
break;
}
}
A. Good
B. Bad
C. compiler error
D. Runtime Error
View Answer & Explanation
Ans. c
Explanation : The case statement can have only constant expressions (this implies that we cannot use variable names directly so an error).
