C | Loops & Control Structure | Question 4
#include <stdio.h> int main() { int i = 3; switch (i) { case 0+1: printf("Geeks"); break; case 1+2: printf("Quiz"); break; default: printf("GeeksQuiz"); } return 0; } |
chevron_right
filter_none
What is the output of the above program?
(A) Geeks
(B) Quiz
(C) GeeksQuiz
(D) Compile-time error
Answer: (B)
Explanation: Expression gets evaluated in cases. The control goes to the second case block after evaluating 1+2 = 3 and Quiz is printed.
Recommended Posts:
- C | Loops & Control Structure | Question 8
- C | Loops & Control Structure | Question 15
- C | Loops & Control Structure | Question 13
- C | Loops & Control Structure | Question 12
- C | Loops & Control Structure | Question 10
- C | Loops & Control Structure | Question 14
- C | Loops & Control Structure | Question 2
- C | Loops & Control Structure | Question 3
- C | Loops & Control Structure | Question 11
- C | Loops & Control Structure | Question 5
- C | Loops & Control Structure | Question 6
- C | Loops & Control Structure | Question 7
- C | Loops & Control Structure | Question 9
- C | Loops & Control Structure | Question 16
- C | Loops & Control Structure | Question 17

