C | Loops & Control Structure | Question 17
Predict the output of the following program:
#include <stdio.h> int main() { int check = 20, arr[] = {10, 20, 30}; switch (check) { case arr[0]: printf("Geeks "); case arr[1]: printf("Quiz "); case arr[2]: printf("GeeksQuiz"); } return 0; } |
chevron_right
filter_none
(A) Quiz
(B) Quiz GeeksQuiz
(C) GeeksQuiz
(D) Compile-time error
Answer: (D)
Explanation: The case labels must be constant inside switch block. Thats why the compile-time error: case label does not reduce to an integer constant is flashed.
Quiz of this Question
Recommended Posts:
- C | Loops & Control Structure | Question 11
- C | Loops & Control Structure | Question 16
- 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



