0

I have to print square matrix from 1 to n² anticlockwise direction starting from center, idk why it is printing 0.

When printing each one individually, it is printing correctly but when i print it in matrix form using loops it is printing 0 https://code.sololearn.com/chq3OPe135Ce/?ref=app

5th Sep 2022, 2:54 PM
Kishan Khanna
Kishan Khanna - avatar
2 Answers
+ 2
It would be helpful to have two different input output examples which shall be generate with this code.
5th Sep 2022, 3:18 PM
JaScript
JaScript - avatar
+ 2
It looks like you just trying to hardcode the solution. Try to print array clock wise first after adding all elements. Then print anticlock wise.. By the way, in 2nd loop, you are starting from arr[x][i] which is arr[1][1] so you skipping arr[1][0] which will be 0 then. same you doing in 3rd loop. since x = 1. not 0
5th Sep 2022, 3:22 PM
Jayakrishna 🇮🇳