COMS 3101-3: Programming Languages (C)

Your program should print the contents of a 2-dimensional array in spiral order. Suppose your array is

 1  2  3  4  5  6
 7  8  9 10 11 12
13 14 15 16 17 18
19 20 21 22 23 24

The output should be:

1 2 3 4 5 6 12 18 24 23 22 21 20 19 13 7 8 9 10 11 17 16 15 14

Your program should take m and n as inputs, where m and n specify the dimensions of the array. Once the user inputs m and n, the program should initialize the array with random numbers using the rand() function.

a[i][j] = rand()%20;

Include the stdlib.h library since rand() requires it.

Once the array is initialized, print the actual contents of the array. Then, compute and print the array in spiral order.

Happy Rotating!