#include<stdio.h>//header file
#include<conio.h>//header file
void main() //starting of the main() function
{
int a[3][3],b[3][3],i,j;//declaration of the variables
clrscr();
printf("program that transpose a given square matrix");
printf("\n\n\n\t\t------------INPUT-------------");
printf("\n\nenter the elements in the matrix");//taking input from the user
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("\na[%d][%d] :->",i,j);
scanf("%d",&a[i][j]);
}
}
printf("\n\nthe original matrix is given by:");
printf("\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("a[%d][%d] :->%d\t",i,j,a[i][j]);
}
printf("\n");
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
b[j][i]=a[i][j];
}
}
printf("\n\n\n\t\t------------OUTPUT------------");
printf("\n\nthe transpose matrix is=");//printing output
printf("\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("b[%d][%d] :->%d\t",i,j,b[i][j]);
}
printf("\n");
}
getch();
}