fastread homefastrread library fastread menu

C : Find Transpose of a Matrix

Tutorial by:Manisha Dubey      Date: 2016-06-17 04:02:44

❰ Previous Next ❱

This program asks user to enter a matrix (size of matrix is specified by user) and this program finds the transpose of that matrix and displays it.

Source Code to Find Transpose of a Matrix

#include <stdio.h>
int main()
    int a[10][10], trans[10][10], r, c, i, j;
    printf("Enter rows and column of matrix: ");
    scanf("%d %d", &r, &c);

/* Storing element of matrix entered by user in array a[][]. */
    printf("\nEnter elements of matrix:\n");
    for(i=0; i<r; ++i)
    for(j=0; j<c; ++j)
        printf("Enter elements a%d%d: ",i+1,j+1);
/* Displaying the matrix a[][] */
    printf("\nEntered Matrix: \n");
    for(i=0; i<r; ++i)
    for(j=0; j<c; ++j)
        printf("%d  ",a[i][j]);

/* Finding transpose of matrix a[][] and storing it in array trans[][]. */
    for(i=0; i<r; ++i)
    for(j=0; j<c; ++j)

/* Displaying the transpose,i.e, Displaying array trans[][]. */
    printf("\nTranspose of Matrix:\n");
    for(i=0; i<c; ++i)
    for(j=0; j<r; ++j)
        printf("%d  ",trans[i][j]);
    return 0;


Enter rows and column of matrix: 2

Enter elements of matrix:
Enter elements a11: 1
Enter elements a12: 2
Enter elements a13: 9
Enter elements a21: 0
Enter elements a22: 4
Enter elements a23: 7

Entered Matrix:
1  2  9

0  4  7

Transpose of Matrix:
1  0

2  4

9  7

❰ Previous Next ❱


Submit Your Thought, Tutorial, Articls etc.

Submit Your Information India's Number one online promotion website