ProgrammingHardTCS NQT · Accenture pattern

What will be the output of the following pseudocode (2x2 matrix multiplication)?

What will be the output of the following pseudocode (2x2 matrix multiplication)?
Integer A[2][2] = {{1, 2}, {3, 4}}
Integer B[2][2] = {{5, 6}, {7, 8}}
Integer C[2][2] = {{0, 0}, {0, 0}}
for (each i from 0 to 1)
    for (each j from 0 to 1)
        for (each k from 0 to 1)
            C[i][j] = C[i][j] + A[i][k] * B[k][j]
        end for
    end for
end for
Print C
  1. A. [[19, 22], [43, 50]]
  2. B. [[5, 12], [21, 32]]
  3. C. [[19, 43], [22, 50]]
  4. D. [[17, 20], [41, 48]]

Correct answer: A. [[19, 22], [43, 50]]

Standard matrix multiplication: C[0][0]=1*5+2*7=19, C[0][1]=1*6+2*8=22, C[1][0]=3*5+4*7=43, C[1][1]=3*6+4*8=50.

More Pseudocode and Code Tracing questions

Exams that ask this topic