C Program to Compute Transpose of Matrix
Write C Program to Compute Transpose of Matrix
// C Program to Compute Transpose of Matrix #include<stdio.h> int main() { int A[3][3]={ {2, 1, 6}, {9, 5, 1}, {4, 3, 8} }; int i, j; printf("Matrix A :--> \n"); for(i = 0;i < 3; i++) { for( j = 0; j < 3; j++) { printf("%d ", A[i][j]); } printf("\n"); } printf("\nTranspose of Matrix A :--> \n"); for(i = 0; i < 3; i++) { for(j = 0; j < 3; j++) { printf("%d ", A[j][i]); } printf("\n"); } return 0; }
Output:
Matrix A :-->
2 1 6
9 5 1
4 3 8
Transpose of Matrix A :-->
2 9 4
1 5 3
6 1 8