ProgrammingVery hardTCS NQT · Wipro

What is printed?

What is printed?
#include <stdio.h>
int main(void) {
    int c = 0;
    for (int i = 0; i < 5; i++) {
        switch (i) {
            case 1: continue;
        }
        c++;
    }
    printf("%d", c);
}
  1. A. 5
  2. B. 3
  3. C. 2
  4. D. 4

Correct answer: D. 4

continue inside a switch applies to the enclosing loop, so i = 1 skips the increment. The increments happen for i = 0, 2, 3 and 4.

More C Programming questions

Exams that ask this topic