Spiral Print clockwise

Why my both testcases failed but in custom input gives right answer.

@shardul15,
your code gives wrong answer for the input:
3 4
1 2 3 4
5 6 7 8
9 10 11 12

@sanchit.bansal06 can you share a code

@shardul15,
https://ide.codingblocks.com/s/262009 you can refer to this

@sanchit.bansal06 i can see the error but why these should be happen can you explain me

@shardul15,
you have taken bottom twice. When dir==2, you need to take right instead of bottom. Hence the error

oh ho ya @sanchit.bansal06 thank you sir