From :- https://aticleworld.com/interview-questions-on-bitwise-operators-in-c/
In this question, you need to count flipped bits that require to convert A to B. To accomplish this task you need to find the number of bits that are different in A and B.
Algorithm
- Calculate XOR of A and B.With the help of XOR, we will discard the common bits and set the bits that are different in numbers A and B.
- Count the set bits of the above calculated XOR result.
Example code,
This comment has been removed by a blog administrator.
ReplyDelete