ProgrammingVery hardTCS NQT · Infosys · Accenture

What will be the output of the following pseudocode?

What will be the output of the following pseudocode?
Integer M[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}, s = 0
for (each i from 0 to 2)
    s = s + M[i][i] * M[i][2 - i]
end for
Print s
  1. A. 45
  2. B. 15
  3. C. 91
  4. D. 81

Correct answer: C. 91

1 x 3 + 5 x 5 + 9 x 7 = 3 + 25 + 63 = 91.

More Pseudocode and Code Tracing questions

Exams that ask this topic