Transpose Of a Matrix
#include<stdio.h>
void main()
{
int a[10][10],b[10][10],i,j,m,n;
printf(" Enter row and column of Matrix A : \n");
scanf("%d%d",&m,&n);
printf ("Input elements of Matrix A: \n");
for ( i=0; i<m;i++)
for (j=0;j<n;j++)
scanf("%d", &a[i][j]);
for (i=0;i<m;i++)
for (j=0;j<n;j++)
b[i][j] = a[j][i];
printf("The transpose of A is: \n");
for (i =0; i<m;i++)
{
for (j=0;j<n;j++)
printf("%5d",b[i][j]);
}
getch();
}
#include<stdio.h>
void main()
{
int a[10][10],b[10][10],i,j,m,n;
printf(" Enter row and column of Matrix A : \n");
scanf("%d%d",&m,&n);
printf ("Input elements of Matrix A: \n");
for ( i=0; i<m;i++)
for (j=0;j<n;j++)
scanf("%d", &a[i][j]);
for (i=0;i<m;i++)
for (j=0;j<n;j++)
b[i][j] = a[j][i];
printf("The transpose of A is: \n");
for (i =0; i<m;i++)
{
for (j=0;j<n;j++)
printf("%5d",b[i][j]);
}
getch();
}
No comments:
Post a Comment