Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

C | Loops & Control Structure | Question 17

  • Difficulty Level : Easy
  • Last Updated : 28 Jun, 2021

Predict the output of the following program:

Take a step-up from those "Hello World" programs. Learn to implement data structures like Heap, Stacks, Linked List and many more! Check out our Data Structures in C course to start learning today.




#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;
}

(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

My Personal Notes arrow_drop_up
Recommended Articles
Page :