Flipkart interview question

GIven a binary number, write a code to convert it into gray code.