Arrays-Spiral Print Anticlockwise

can u help me solve below (cpp program appreciated)

Take as input a 2-d array. Print the 2-D array in spiral form anti-clockwise.
Input Format

Two integers M(row) and N(colomn) and further M * N integers(2-d array numbers).
Constraints

Both M and N are between 1 to 10.
Output Format

All M * N integers separated by commas with ‘END’ written in the end(as shown in example).
Sample Input

4 4
11 12 13 14
21 22 23 24
31 32 33 34
41 42 43 44

Sample Output

11, 21, 31, 41, 42, 43, 44, 34, 24, 14, 13, 12, 22, 32, 33, 23, END

Explanation

For spiral level anti-clockwise traversal, Go for first column-> last row ->last column-> first row and then do the same traversal for the remaining matrix .

hello @Kash-Moulik-3715574511847721

In sprial print anti-clockwise, we need to print elements of first column then elements of last row then elements of last column then elements of first row and so on until all the elements of the matrix are printed. In the given case first the elements of 0th column then of 3rd row then of 3rd column then of 0th row then of 1st column then of 2nd row then of 2nd column are printed.Thus, elements are printed column and row wise alternatively forming an anti-clockwise loop.
image

so just use four loops (each loop for printing one row or cloumn).
check this code->