Write a ‘C’ program to display the transpose of a given 3X3 matrix.

#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],i,j;
clrscr();
printf("enter the elements\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("matrix\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d",a[i][j]);
}
printf("\n");
}
printf("-------------------------\n");
printf("transpose\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d",a[j][i]);
}
printf("\n");
}
getch();
}

Comments

  1. Thanks
    Nice code ease to understand.
    Its my suggestion if possible it implement in C++. because most of the programe based on matrix available in C.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Transpose of a matrix means rotating a matrix by 90 degrees. First row will become first column and first column will become first row of matrix.

    ReplyDelete
  4. Thank you very much for this code. It is very helpful.

    ReplyDelete

Post a Comment