🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Matrix Programs in C: all 10 questions

Quiz: Matrix Programs in C · Question 9 of 10

In-place transpose of a square matrix swaps a[i][j] with a[j][i]. Why must j start at i + 1?

In-place transpose of a square matrix swaps a[i][j] with a[j][i]. Why must j start at i + 1?

  1. A.To skip the last row
  2. B.Starting at 0 swaps every pair twice, which puts the matrix back as it was
  3. C.Because a[i][i] cannot be read
  4. D.To avoid integer overflow
Answer & explanation

Correct answer: Starting at 0 swaps every pair twice, which puts the matrix back as it was

Each pair must be swapped exactly once, so only the part above the diagonal is visited.

Can you get the rest right without peeking?

Take the timed Quiz: Matrix Programs in C quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →