Transpose of matrix in c language.
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],T[3][3],i,j;
clrscr();
printf("enter the 9 numbers for matrix=");
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
{
scanf("%d",&a[i][j]);
}
}
printf("before transpose the matrix=\n");
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
{
printf("%d\t",a[i][j]);
}
printf("\n");
}
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
{
T[j][i]=a[i][j];
}
}
printf("after the transpose matrix is=\n");
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
{
printf("%d\t",T[i][j]);
}
printf("\n");
}
getch();
}
■》Output->
enter the 9 numbers for matrix=1
3
4
2
6
4
8
5
8
before transpose the matrix=
1 3 4
2 6 4
8 5 8
after the transpose matrix is=
1 2 8
3 6 5
4 4 8
Comments
Post a Comment