Open In App
Related Articles

C | Loops & Control Structure | Question 17

Improve Article
Improve
Save Article
Save
Like Article
Like

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


(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

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 28 Jun, 2021
Like Article
Save Article
Previous
Next
Similar Reads