ProgrammingVery hardTCS NQT · Infosys

int r = 0; switch (2) { case 1: r += 1; case 2: r += 10; case 3: r += 100; break; default: r += 1000; } What is r?

  1. A. 10
  2. B. 110
  3. C. 100
  4. D. 1110

Correct answer: B. 110

Case 2 matches and adds 10, then control falls through to case 3, which adds 100, and the break stops the switch. The total is 110.

More C Programming questions

Exams that ask this topic