am i missing something in the next palindrome

i dont know why my code is giving wrong answer , it works very fine on my machine , suggest test case here’s the link http://www.codechef.com/viewsolution/3957884

@ana1nd_9 it is quite difficult to understand ones code so i suggest you to have a look on my code i think then you will get where are you missing if even not then feel free to comment here again.

here is the link to my code http://www.codechef.com/viewsolution/3644295

here is link to my code http://www.codechef.com/viewsolution/3644295

//