Program to find the transpose of a matrix in C, C++, Java and Python | faceprep

Program to find the transpose of a matrix in C, C++, Java and Python | faceprep

The program to find the transposition of a matrix is discussed here. Transpose of a matrix can be performed by exchanging the elements of a row by column and the elements of a column by row.



Program to find the transpose of a matrix in C, C++, Java and Python | FACE Prep



For example:


Input:nn1 2 3n4 5 6n7 8 9nnoutput:nn1 4 7n2 5 8n3 6 9nn


Algorithm:


Program to find the transpose of a matrix in C, C++, Java and Python | FACE Prep

Consider the matrix:

m[0][0] = 10

m[0][1] = 20

m[1][0] = 30

m[1][1] = 40

m[2][0] = 50

m[2][1]= 60



Program to find the transpose of a matrix in C, C++, Java and Python | FACE Prep

The transposition of the above matrix can be done by this way:

r_m[0][0] = m[0][0] = 10

r_m[0][1] = m[1][0] = 30

r_m[0][2] = m[2][0] = 50

r_m[1][0] = m[0][1] = 20

r_m[1][1] = m[1][1] = 40

r_m[1][2] = m[2][1] = 60


Program to find the transpose of a matrix


Asked in recruitment drive of Wipro.n


@@coding::1@@



Recommended Programs








Program to find the transpose of a matrix in C, C++, Java and Python | FACE Prep