Skip to content

Instantly share code, notes, and snippets.

@nahiyan
Created November 21, 2016 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nahiyan/b1605538bb44d6d71dc58c02fd9f0704 to your computer and use it in GitHub Desktop.
Save nahiyan/b1605538bb44d6d71dc58c02fd9f0704 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#define W 3
#define H 2
void inputMatrix (int matrix[H][W]) {
int i, j;
for (i = 0; i < H; i++) {
for (j = 0; j < W; j++) {
scanf("%d", &matrix[i][j]);
}
}
}
void transposeMatrix (int matrix[H][W]) {
int i, j;
for (i = 0; i < W; i++) {
for (j = 0; j < H; j++) {
printf("%d ", matrix[j][i]);
}
printf("\n");
}
}
int main () {
int matrix[H][W];
printf("Enter a matrix:\n");
inputMatrix(matrix);
printf("Transpose of matrix:\n");
transposeMatrix(matrix);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment