C Program to find the transpose of a matrix

The following is a C program to find the transpose of a matrix:

Expected Output:

How it works

Let A be a matrix of size m x n,  then the matrix obtained by interchanging the rows and columns is called the Transpose of A.

The transpose of a matrix is denoted by AT . For example:

A =  \left(\begin{array}{cc}1 & 2\\3 & 4\\5 & 6\end{array}\right) 

then, A^T = \left(\begin{array}{ccc}1 & 3 & 5\\2 & 4 & 6\end{array}\right) 

Here is how the program works:

  1. The first for loop (lines 16-22) asks the user to input the matrix.
  2. The second for loop (lines 27-33) creates the transpose matrix by interchanging rows with columns.
  3. The third for loop (lines 38-46) prints the transpose of a matrix.

Recommended Reading:

Leave a Comment

%d bloggers like this: