Discussion
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.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development