Skip to content
Related Articles

Related Articles

C | Loops & Control Structure | Question 4

View Discussion
Improve Article
Save Article
  • Difficulty Level : Basic
  • Last Updated : 12 Jan, 2013

#include <stdio.h>
int main()
    int i = 3;
    switch (i)
        case 0+1: printf("Geeks");
        case 1+2: printf("Quiz");
        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.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!