Anti Clockwise Spiral Print

Can you go through my code and let me know my mistake.
My ans is coming out wrong in a 3*8 matrix. What can I do to resolve it.

hi @Anaghajain,


Your logic is correct,in your code it was printing extra elements.You can fix them by checking when it has printed n*m elements and stop the code.
Please let me know if there is any other doubt.

1 Like

Thank you very much! My code worked perfectly now!

1 Like