Predict the output of the below program:
#include <stdio.h>
int main()
{
int i = 3;
switch(i)
{
printf("Outside ");
case 1: printf("Geeks");
break;
case 2: printf("Quiz");
break;
defau1t: printf("GeeksQuiz");
}
return 0;
}
Answer: C
Correct answer: Nothing gets printed
Two things happen here. The printf("Outside ") sits inside the switch body but before any label, so control never reaches it - a switch jumps straight to a matching label. And defau1t is spelt with the digit one, so it is an ordinary goto label, not the default case. With i equal to 3 nothing matches and there is no real default, so the switch does nothing at all.
Please log in or register to report this question.