Write a Program in C to take elements of a matrix[3][3] and find the transpose of matrix.
#include
int main()
{
int mat[3][3],i,j;
printf("Enter the elements of matrix 3X3\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&mat[i][j]);
}
}
printf("Original Mtrix is:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d \t",mat[i][j]);
}
printf("\n");
}
printf("Transpoose of Mtrix is:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d \t",mat[j][i]);
}
printf("\n");
}
return 0;
}
Enter the elements of matrix 3X3
Original Mtrix is:
1 2 3
4 5 6
7 8 9
Transpose of Mtrix is:
1 4 7
2 5 8
3 6 9
Comments
Post a Comment