KodeGod.com

080. Write a program to accept a M x N matrix and print it’s transpose matrix in C language

#include<stdio.h>
main()
{
    int i,j,m,n,a[5][5];
    printf("Enter order of matrix :\n");
    scanf("%d%d",&m,&n);
    printf("Enter matrix elements.....\n");
    for(i=0;i<m;i++)
        for(j=0;j<n;j++)
            scanf("%d",&a[i][j]);
 
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
            printf("%d ",a[j][i]);
        printf("\n");
    }
    getch();
}