Bitwise Interview Question

Is the code that u have written is correct