Sum with xor

Please share the logic in deep and the code if possible. I am stuck with this question from a long time.