C | Loops & Control Structure | Question 14
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; } |
chevron_right
filter_none
(A) Outside GeeksQuiz
(B) GeeksQuiz
(C) Nothing gets printed
Answer: (C)
Explanation: In a switch block, the control directly flows within the case labels(or dafault label). So, statements which do not fall within these labels, Outside is not printed. Please take a closer look at the default label. Its defau1t, not default which s interpreted by the compiler as a label used for goto statements. Hence, nothing is printed in the above program.
Quiz of this Question
Recommended Posts:
- C | Loops & Control Structure | Question 18
- C | Loops & Control Structure | Question 2
- C | Loops & Control Structure | Question 8
- C | Loops & Control Structure | Question 1
- C | Loops & Control Structure | Question 12
- C | Loops & Control Structure | Question 19
- C | Loops & Control Structure | Question 13
- C | Loops & Control Structure | Question 10
- C | Loops & Control Structure | Question 11
- C | Loops & Control Structure | Question 15
- C | Loops & Control Structure | Question 16
- C | Loops & Control Structure | Question 17
- C | Loops & Control Structure | Question 21
- C | Loops & Control Structure | Question 9
- C | Loops & Control Structure | Question 20



