Recently, I encountered with a problem that asked me to write a dynamic code that print `n x n` matrix in a `zigzag` pattern. Please help me with the code to get the output stated below.

Output:

```
rows: 5
cols: 5

 1  2  3  4  5

10  9  8  7  6

11 12 13 14 15

20 19 18 17 16

21 22 23 24 25

```

The Code that I've tried so far is in static:

```
#include <stdio.h>

int main(){

int arr[3][3]={1,2,3,
         4,5,6,
         7,8,9};

int i, j, k;

for(i=0; i<3; i++){
    printf("%d",arr[0][i]);
}
    printf("\n");
for(j=2; j>=0; j--){
    printf("%d",arr[1][j]);
}
printf("\n");
for(k=0; k<3; k++){
    printf("%d",arr[2][k]);
}
printf("\n");
return 0;

}

```

Now I want the same thing to be done with the user stating rows and columns of an array..