/* Program to find out the transpose of a square matrix */ /* Problem 15 */ #include #include main() { int n,i,j; int mat[5][5]; clrscr(); printf("Please enter the dimension of the square matrix : "); scanf("%d",&n); printf("\nPlease enter the %d elements (separated by or )",n*n); printf("\n\n"); for (i = 0; i < n; i++) for (j = 0; j < n; j++) scanf("%d",&mat[i][j]); printf("\nThe square matrix you entered, was :"); printf("\n\n"); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) printf(" %2d ",mat[i][j]); printf("\n"); } printf("\nThe transpose of the above matrix is as follows, "); printf("\n\n"); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) printf(" %2d ",mat[j][i]); printf("\n"); } printf("\nPress any key to exit..."); getch(); }