C | Loops & Control Structure | Question 16
What is the output of the following program?
#include <stdio.h> int main() { char check = 'a'; switch (check) { case 'a' || 1: printf("Geeks "); case 'b' || 2: printf("Quiz "); break; default: printf("GeeksQuiz"); } return 0; } |
chevron_right
filter_none
(A) Geeks
(B) Geeks Quiz
(C) Geeks Quiz GeeksQuiz
(D) Compile-time error
Answer: (D)
Explanation: An expression gets evaluated in a case label. Both the cases used are evaluated to 1(true). So compile-time error: duplicate case value is flashed as duplicated cases are not allowed.
Quiz of this Question
Recommended Posts:
- C | Loops & Control Structure | Question 11
- C | Loops & Control Structure | Question 17
- C | Loops & Control Structure | Question 15
- C | Loops & Control Structure | Question 18
- C | Loops & Control Structure | Question 19
- C | Loops & Control Structure | Question 14
- C | Loops & Control Structure | Question 21
- C | Loops & Control Structure | Question 20
- C | Loops & Control Structure | Question 13
- C | Loops & Control Structure | Question 8
- C | Loops & Control Structure | Question 9
- C | Loops & Control Structure | Question 1
- C | Loops & Control Structure | Question 5
- C | Loops & Control Structure | Question 6
- C | Loops & Control Structure | Question 10



