# Transpose of a Matrix in C

## C Program to find the Transpose of a Matrix

• In this problem, we are to find the transpose of an input matrix.
• Transpose of a matrix is obtained by interchanging rows and columns. In other words, transpose of A[][] is obtained by changing A[i][j] to A[j][i].
`#include <stdio.h>int main (){    int a[10][10], t[10][10], r, c, i, j;    printf ("Enter the order of matrix: ");    scanf ("%d %d", &r, &c);    printf ("\nEnter the elements of matrix:\n");    for (i = 0; i < r; ++i)    {        for (j = 0; j < c; ++j)	    {	        printf ("Enter the element a[%d %d]: ", i + 1, j + 1);	        scanf ("%d", &a[i][j]);	    }    }      printf ("\nInput Matrix: \n");    for (i = 0; i < r; ++i)    {        for (j = 0; j < c; ++j)	    {	        printf ("%d ", a[i][j]);	        if (j == c - 1)	            printf ("\n\n");	    }    }    for (i = 0; i < r; ++i)    {        for (j = 0; j < c; ++j)	    {	        t[j][i] = a[i][j];	    }    }    printf ("\nTranspose of the Input Matrix:\n");    for (i = 0; i < c; ++i)    {        for (j = 0; j < r; ++j)	    {	        printf ("%d ", t[i][j]);	        if(j == r - 1)	           printf ("\n\n");	    }    }    return 0;}`