Program to Print Transpose of a Matrix in C

Print Transpose of a Matrix in C

#include <stdio.h>
main()
{
          int a[10][10], i, j, row, col;
          printf(" Enter no. of rows & columns: ");
          scanf("%d %d", &row, &col);

          printf(" Enter elements of Matrix: ");
          for (i=0; i<row; i++)
          for (j=0; j<col; j++)
          scanf("%d", &a[i][j]); 

          printf(" Elements of Matrix: ");
         
           for (i=0; i<row; i++)
          {
                    for (j=0; j<col; j++)
                    printf(" %d", a[i][j]);
                    printf(" ");
          }
 
          printf(" Transpose of Matrix: ");
          for (i=0; i<col; i++)
          {
                    for (j=0; j<row; j++)
                    printf(" %d", a[j][i]);
                    printf(" ");
          }

          getch();

}