Delhi's ODDEVEN

I have dry run my code and tried to think in every possible way but cannot understand why is my code giving wrong answers, it looks to be complete right. on dry running it gives correct answer, where am i wrong.

Please save your code and send the link…