/* Transpose of a matrix. */
#include <stdio.h>
int main()
{
int n, m, i, j, sum;
printf("Enter the number of rows and columns of matrix: ");
scanf("%d %d", &n, &m);
int a[n][m];
for(i = 0; i < n; i++){
for(j = 0; j < m; j++){
printf("Enter element (%d, %d) of matrix A: ", i+1, j+1);
scanf("%d", &a[i][j]);
}
}
printf("The matrix you entered is.....\n");
for(i = 0; i < n; i++){
for(j = 0; j < m; j++)
printf("%d\t", a[i][j]);
printf("\n");
}
printf("The transpose of your matrix is.....\n");
for(i = 0; i < n; i++){
for(j = 0; j < m; j++)
printf("%d\t", a[j][i]);
printf("\n");
}
return 0;
}
Comments
Post a Comment