Question 36Asked in DSSSB TGT Computer Science (Technical), 12 Sep 2025, Shift 3 (5:00 PM)

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

What is the output of the following code? #include <stdio.h> int main() { for (int i = 1; i <= 3; i++) { for (int j = 1; j <= i; j++) { printf("*"); } printf("\n"); } return 0; }
  1. A* ** ***
  2. B*** ** *
  3. C*** *** ***
  4. DCompilation Error
Show answerHide answer

Correct answer: (A) * ** ***

Explanation

The outer loop runs i = 1 to 3, and the inner loop prints i stars each time, so the rows are *, ** and ***.

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

This is question 36 of DSSSB TGT Computer Science PYQ (Technical), 12 Sep 2025, Shift 3 (5: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.