I am only passing 2 testcase and i am unable to process what to do now.help me out

after the while loop ends the value of n become 0…so you have to store the value of n in some temp variable…refer to this code(i have put various comments for better understanding)