reversing 2d array row to column and column to row in c

Solutions on MaxInterview for reversing 2d array row to column and column to row in c by the best coders in the world

showing results for - "reversing 2d array row to column and column to row in c"
Eliott
15 Jun 2016
1int ara[5][5],ara2[5][5];
2    printf("Enter rows and columns:\n");
3    int i,j;
4    for(i=0;i<5;i++){
5        for(j=0;j<5;j++){
6            printf("(%d %d):\n",i,j);
7            scanf("%d",&ara[i][j]);
8        }
9    }
10
11
12    printf("newly created array:\n");
13    for(i=0;i<5;i++){
14        for(j=0;j<5;j++){
15            printf("%d ",ara[i][j]);
16
17        }
18        printf("\n");
19    }
20
21    for(i=0;i<5;i++){
22        for(j=0;j<5;j++){
23          ara2[j][i]=ara[i][j];
24
25        }
26
27    }
28
29    printf("After customizing:\n");
30    for(i=0;i<5;i++){
31        for(j=0;j<5;j++){
32            printf("%d ",ara2[i][j]);
33
34        }
35        printf("\n");
36    }
37
38