YouTip LogoYouTip

C Examples Matrix Transpose

# C Example - Matrix Transposition [![Image 3: C Examples](#) C Examples](#) Matrix transposition. ## Example ```c #include int main() { int a, transpose, r, c, i, j; printf("Enter rows and columns: "); scanf("%d %d", &r, &c); /* Storing elements of the matrix */ printf("nEnter elements of matrix:n"); for(i=0; i<r; ++i) for(j=0; j<c; ++j) { printf("Enter element a%d%d: ",i+1, j+1); scanf("%d", &a); } /* Displaying the matrix a[][] */ printf("nEntered Matrix: n"); for(i=0; i<r; ++i) for(j=0; j<c; ++j) { printf("%d ", a); if(j == c-1) printf("nn"); } /* Finding the transpose of matrix a */ for(i=0; i<r; ++i) for(j=0; j<c; ++j) { transpose = a; } /* Displaying the transpose of the entered matrix */ printf("nTranspose of the matrix:n"); for(i=0; i<c; ++i) for(j=0; j<r; ++j) { printf("%d ",transpose); if(j==r-1) printf("nn"); } return 0; } Output: Enter rows and columns: 2 3 Enter elements of matrix: Enter element a11: 2 Enter element a12: 3 Enter element a13: 4 Enter element a21: 5 Enter element a22: 6 Enter element a23: 4 Entered Matrix: 2 3 4 5 6 4 Transpose of the matrix: 2 5 3 6 4 4 [![Image 4: C Examples](#) C Examples](#) [](#)(#) (#)[](#)
← C Examples Frequency CharacterC Examples Average Arrays β†’