Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

C | Loops & Control Structure | Question 4

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

C




#include <stdio.h>
 
int main() {
    int i = 3;
    switch (i) {
        case 1:
            printf("Geeks");
            break;
        case 1+2:
            printf("Quiz");
            break;
        default:
            printf("GeeksQuiz");
    }
    return 0;
}


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.


Quiz of this Question
Please comment below if you find anything wrong in the above post

My Personal Notes arrow_drop_up
Last Updated : 12 Jan, 2013
Like Article
Save Article
Similar Reads