ProgrammingHardTCS Digital · Capgemini

What will be the output of the following pseudocode?

What will be the output of the following pseudocode?
Integer m[3][3] = {{2, 0, 1}, {1, 3, 2}, {1, 1, 1}}
Integer det = m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1])
            - m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0])
            + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0])
Print det
  1. A. 4
  2. B. 2
  3. C. 0
  4. D. 6

Correct answer: C. 0

Expanding along the first row: 2(3·1 − 2·1) − 0 + 1(1·1 − 3·1) = 2(1) + 1(−2) = 0. The matrix is singular.

More Pseudocode and Code Tracing questions

Exams that ask this topic