I was given a question and was asked to give the output.
int main(void){
int x = 2;
switch(x){
case 1,2,1: printf(\"Case 1 is executed\
is it a compiler error or not.
It will cause a compilation error (don't know about TURBO C++ but in modern compilers).
This is not the way switch statement works (invalid syntax in c/c++). You cannot reuse a case
value in switch
statement (see the link given by chris) The way you can do this;
switch(x){
case 1: case 2: case 3: printf("Case 1 is executed");
break;
default : printf("Default case us execyted");
}