the before arrays: the after arrays:
1 2 3 4 13 9 5 1
5 6 7 8 14 10 6 2
9 10 11 12 15 11 7 3
13 14 15 16 16 12 8 4
#include<stdio.h> #define N 4 void fun(int a[][N]) { int i,j,m,n; int b[N][N]; for(i=0;i<N;i++) for(j=0;j<N;j++) b[i][j]=a[N-1-j][i]; for(m=0;m<N;m++) for(n=0;n<N;n++) a[m][n]=b[m][n]; } void main() { int i,j; int s[N][N]={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}}; printf("the before arrays: "); for(i=0;i<N;i++) { for(j=0;j<N;j++) printf("%d ",s[i][j]); printf(" "); } fun(s); printf("the after arrays: "); for(i=0;i<N;i++) { for(j=0;j<N;j++) printf("%d ",s[i][j]); printf(" "); } }