Created
November 21, 2016 16:28
-
-
Save nahiyan/b1605538bb44d6d71dc58c02fd9f0704 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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