Write a c program to transpose a matrix.

#include<stdio.h>

#include<conio.h>

  main()

{

  int a[10][10],b[10][10];

  int i,j,m,n;

  clrscr();

  printf(" \n enter the row and column of matrix");

  scanf("\n %d%d",&m,&n);

  printf("\n enter the elements of matrix");

  for(i=0;i<m;i++)

{

  for(j=0;j<n;j++)

{

  scanf("%d",&a[i][j]);

}

}

  for(i=0;i<m;i++)

{

  for(j=0;j<n;j++)

{

  printf("\n matrix =%d",a[i][j]);

}

}

  for(i=0;i<m;i++)

{

  for(j=0;j<n;j++)

{

  b[i][j]=0;

}

}

  for(i=0;i<m;i++)

{

  for(j=0;j<n;j++)

{

  b[i][j]=a[[j][i];

  printf("\n tranceposed matrix =%d",b[i][j]);

}

}

  return (0);

}



 output:-

  enter the row and column of matrix =3*3
  enter the element of matrix[a]=1,2,3,4,5,6,7,8,9
  matrix[a]=  1 2 3
                   4 5 6
                   7 8 9
  transpose of matrix[b]=  1 4 7
                                      2 5 8
                                      3 6 9