Transpose of a matrix is obtained by changing rows to columns and columns to rows. In other words, transpose of A is obtained by changing A[i][j] to A[j][i].
- Create a 2-D Array.
- Insert the values in the array by running two nested loops. The outer ith loop will go till the no.of rows and the inner jth loop will run till the number of columns.
- For displaying the transpose of the matrix, run the same loop as explained in the above step but print the a[j[i] th element every time we are traversing inside the loop.
enter the elements of matrix Matrix before Transpose 1 2 3 4 5 6 7 8 9 Matrix After Transpose 1 4 7 2 5 8 3 6 9
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.