Question 26Asked in DSSSB TGT Computer Science (Technical), 12 Sep 2025, Shift 1 (9:00 AM)

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

What is the output of the following code? #include <stdio.h> int main() { int i = 5; do { printf("%d ", i); i--; } while (i > 5); return 0; }
  1. ANo output printed
  2. BInfinite loop
  3. C5 4 3 2 1
  4. D5
Show answerHide answer

Correct answer: (D) 5

Explanation

A do-while body runs at least once, so 5 is printed. Then i becomes 4 and the condition 4 > 5 is false, so the loop ends.

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

This is question 26 of DSSSB TGT Computer Science PYQ (Technical), 12 Sep 2025, Shift 1 (9:00 AM). 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.