-
Notifications
You must be signed in to change notification settings - Fork 0
/
twodarray3.c
52 lines (49 loc) · 1.11 KB
/
twodarray3.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
49
50
51
52
#include<stdio.h>
int main(int argc, char const *argv[])
{
int i,j,numOfRows,numOfCols;
int A[10] [10],transpose[10][10];
printf("Enter the numnber of rows & cols= ");
scanf("%d %d",&numOfRows,&numOfCols);
//scanning A matrix
printf("Enter element of A matrix=\n ");
for(i=0; i<numOfRows; i++)
{
for(j=0; j<numOfCols; j++)
{
printf("A[%d][%d]= ",i,j);
scanf("%d",&A[i] [j]);
}
printf("\n");
}
//print A matrix
printf("\nEntered matrix= \n");
for(i=0; i<numOfRows; i++)
{
for(j=0; j<numOfCols; j++)
{
printf("%d ",A[i] [j]);
}
printf("\n");
}
//transpose matrix
for(i=0; i<numOfRows; i++)
{
for(j=0; j<numOfCols; j++)
{
transpose[j][i]=A[i][j];
}
printf("\n");
}
//print transpose matrix
printf("\ntranspose matrix= \n");
for(i=0; i<numOfCols; i++)
{
for(j=0; j<numOfRows; j++)
{
printf("%d ",transpose[i] [j]);
}
printf("\n");
}
return 0;
}