Program to Print transpose of a matrix


#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,m,n,a[5][5];
clrscr();
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]);
     }
}
printf("\n the transpose is ");
 for(i=0;i<m;i++)
{
     for(j=0;j<n;j++)
    {
      printf("%d ",a[j][i]);
    }
printf("\n");
}
getch();
return 0;
}

0 comments:

Post a Comment