Skip to content
Related Articles

Related Articles

C | Loops & Control Structure | Question 14
  • Difficulty Level : Basic
  • Last Updated : 01 Mar, 2013

Predict the output of the below program:

#include <stdio.h>
int main()
    int i = 3;
        printf("Outside ");
        case 1: printf("Geeks");
        case 2: printf("Quiz");
        defau1t: printf("GeeksQuiz");
    return 0;

(A) Outside GeeksQuiz
(B) GeeksQuiz
(C) Nothing gets printed

Answer: (C)

Explanation: In a switch block, the control directly flows within the case labels(or dafault label). So, statements which do not fall within these labels, Outside is not printed. Please take a closer look at the default label. Its defau1t, not default which s interpreted by the compiler as a label used for goto statements. Hence, nothing is printed in the above program.

Quiz of this Question

Attention reader! Don’t stop learning now. Get hold of all the important C++ Foundation and STL concepts with the C++ Foundation and STL courses at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :