-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUntitled2.c
More file actions
63 lines (42 loc) · 1.04 KB
/
Untitled2.c
File metadata and controls
63 lines (42 loc) · 1.04 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include<stdio.h>
int transpose(int (*arr)[5], int row, int col);
int main(){
int arr[5][5];
int i, j, row,col;
printf ("Enter the number of rows in the matrix\n");
scanf("%d", &row);
printf ("Enter the number of columns in matrix\n");
scanf("%d", &col);
printf("Enter elements of the Matrix:\n");
for(i = 0; i < row; i++){
for(j = 0; j < col; j++){
scanf("%d", &arr[i][j]);
}
}
printf("Original Matrix:\n");
for(i = 0; i < row; i++){
for(j = 0; j < col; j++){
printf("%d\t", arr[i][j]);
}
printf("\n");
}
transpose(arr, row, col);
return 0;
}
int transpose(int (*arr)[5], int row, int col){
int i, j;
int trans[5][5];
for(i = 0; i < row; i++){
for(j = 0; j < col; j++){
trans[j][i] = (*arr)[j];
}
arr++;
}
printf("\n Transpose is :\n");
for(i = 0; i < col; i++){
for(j = 0; j < row; j++){
printf("%d\t", trans[i][j]);
}
printf("\n");
}
}