1#include <stdio.h>
2#define N 4
3
4// This function stores transpose of A[][] in B[][]
5void transpose(int A[][N], int B[][N])
6{
7 int i, j;
8 for (i = 0; i < N; i++)
9 for (j = 0; j < N; j++)
10 B[i][j] = A[j][i];
11}
12
13int main()
14{
15 int A[N][N] = { {1, 1, 1, 1},
16 {2, 2, 2, 2},
17 {3, 3, 3, 3},
18 {4, 4, 4, 4}};
19
20 int B[N][N], i, j;
21
22 transpose(A, B);
23
24 printf("Result matrix is \n");
25 for (i = 0; i < N; i++)
26 {
27 for (j = 0; j < N; j++)
28 printf("%d ", B[i][j]);
29 printf("\n");
30 }
31
32 return 0;
33}