Thursday 29 December 2011

C program to find the transpose of a matrix



#include<stdio.h>
main()
{
int a[10][10],b[10][10],i,j,r,c,t;
printf("Enter the order of the matrix\n");
scanf("%d%d",&r,&c);
printf("Enter the values\n");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("\nThe matrix is\n");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
printf("%d\t",a[i][j]);
}
printf("\n");
}
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
b[j][i]=a[i][j];
}
}
printf("Transpose of matrix is\n");
for(i=0;i<c;i++)
{
for(j=0;j<r;j++)
{
printf("%d\t",b[i][j]);
}
printf("\n");
}
}




You Like It!? Then kindly share with your Friends.
Comments
0 Comments

No comments:

Post a Comment