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

What will be the output of the following C program? int main()

What will be the output of the following C program? #include <stdio.h> int main() { int a[5]; for (int i = 0; i < 5; i++) { a[i] = i * i - 2 * i + 1; } for (int i = 0; i < 5; i++) { printf("%d ", a[i]); } return 0; }
  1. A1 0 2 4 9
  2. B1 0 1 4 9
  3. C1 1 2 4 9
  4. D1 2 3 4 9
Show answerHide answer

Correct answer: (B) 1 0 1 4 9

Explanation

i*i - 2*i + 1 = (i - 1)², so for i = 0 to 4 the values are 1, 0, 1, 4, 9.

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

This is question 78 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.