Gray code similar

i do same as done in video but
i am geting wrong ans
my code: https://ide.codingblocks.com/s/115954
question: https://www.codechef.com/problems/GRAYSC