C++ program to find transpose of a matrix

C++ program to find transpose of a matrix
This c program prints transpose of a matrix. It is obtained by interchanging rows and columns of a matrix.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].

 

 

For example if a matrix is

1 2
3 4
5 6

then transpose of above matrix will be

1 3 5
2 4 6

When we transpose a matrix then the order of matrix changes, but for a square matrix order remains same.

Algorithm :

Matrix Transpose means changing the order or arrangement of a matrix. If A be the given matrix, then the matrix formed by interchanging the columns and rows of the matrix  A without changing the value of elements is called as transpose of a matrix. If Am×n = [aij], then AT(n×m) = [aji]
i.e. the (i,j)th element of A is the (j,i)th element of AT. So, in A and AT,

ith column of AT = ith row of A
jth row of AT = jth column of A
In A and AT, the diagonal elements are equal.

Example: C++ program to find transpose of a matrix



Output
Enter the number of  Rows of  Matrix 1 :       1

Enter the number of  Columns of  Matrix 1 :  2
Enter the Element a[0][0] : 8
Enter the Element a[0][1] : 6

Matrix elements is :
8 6

Transpose Matrix elements is :
8
6

Date - 1/26/2013-@author Y.ACHCHUTHAN -cpp.achchuthan.org

Press Enter to return to Quincy...

Example: C++ program to find transpose of a matrix



Output

Enter rows and columns of matrix: 2
3

Enter elements of matrix:
Enter elements a11: 1
Enter elements a12: 2
Enter elements a13: 3
Enter elements a21: 4
Enter elements a22: 5
Enter elements a23: 6

Entered Matrix:
1 2 3

4 5 6


Transpose of Matrix:
1 4

2 5

3 6

2 Comments

Post a Comment

Previous Post Next Post