🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: C Control Flow: all 10 questions

Quiz: C Control Flow · Question 1 of 10

What does this print? (code)

What does this print?

#include <stdio.h>
int main(void) {
    int x = 2;
    switch (x) {
        case 1: printf("A");
        case 2: printf("B");
        case 3: printf("C");
        default: printf("D");
    }
    return 0;
}
  1. A.B
  2. B.BC
  3. C.BCD
  4. D.ABCD
Answer & explanation

Correct answer: BCD

No breaks: execution starts at case 2 and falls through to the end.

Can you get the rest right without peeking?

Take the timed Quiz: C Control Flow quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →