How to transpose matrix in C?

Below code will help you to program for transpose of matrix

#include<stdio.h>
#include<conio.h>
void main ()
{
int a[2][2],i,j;
clrscr();
printf(“Enter number for matrix\n”);
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
scanf(“%d”,&a[i][j]);
}
}
printf(“Your matrix is here:-\n”);
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
printf(“%d\t”,a[i][j]);
}
printf(“\n”);
}
printf(“swap of matrix:\n”);

for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
printf(“%d\t”,a[j][i]);
}
printf(“\n”);
}

getch();
}

After running above program 🙂