Question 38Asked in DSSSB TGT Computer Science (Technical), 12 Sep 2025, Shift 2 (1:00 PM)

What will be the output of the following code? int main() {

What will be the output of the following code? #include <stdio.h> int main() { int a = 2, b = 3; switch (a) { case 1: printf("Case 1"); break; case 2: switch (b) { case 3: printf("Case 3"); break; default: printf("Inner Default"); } default: printf("Outer Default"); } return 0; }
  1. ACase 3Inner Default
  2. BCase 3
  3. CInner DefaultOuter Default
  4. DCase 3Outer Default
Show answerHide answer

Correct answer: (D) Case 3Outer Default

Explanation

a = 2 selects case 2; the inner switch matches case 3, prints "Case 3", and its break exits only the inner switch. With no break after it, control falls into the outer default and prints "Outer Default".

From DSSSB TGT Computer Science PYQ (Technical), 12 Sep 2025, Shift 2 (1:00 PM)

This is question 38 of DSSSB TGT Computer Science PYQ (Technical), 12 Sep 2025, Shift 2 (1:00 PM). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.