-
Notifications
You must be signed in to change notification settings - Fork 0
/
transpose.c
48 lines (42 loc) · 926 Bytes
/
transpose.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <stdio.h>
void main()
{
int i, j, row, column;
printf("Enter number of rows: ");
scanf("%d", &row);
printf("\nEnter number of columns: ");
scanf("%d", &column);
int array[row][column];
for (i = 0; i < row; i++)
{
for (j = 0; j < column; j++)
{
printf("\nEnter Elements: ");
scanf("%d", &array[i][j]);
}
}
for (i = 0; i < row; i++)
{
for (j = 0; j < column; j++)
{
printf("%d ",array[i][j]);
}
printf("\n");
}
int transpose[column][row];
for (i = 0; i < row; i++)
{
for (j = 0; j < column; j++)
{
transpose[j][i] = array[i][j];
}
}
for (i = 0; i < column; i++)
{
for (j = 0; j < row; j++)
{
printf("%d ",transpose[i][j]);
}
printf("\n");
}
}