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();
}

1 comment:

  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