Write a C program to encode bits in a 32-bit number such that, most significant 16 bits should be reversed but lower 16 bits should be untouched. Then asked to generalize this to any number of bits.
Sigiloso
The idea is to reverse the entire 32-bits first and then left shift the resulting number by 16 bits so that the upper 16 bits are now reversed. In the second phase, with the help of a mask zero out the most significant 16 bits. Now XOR the two number to get the desired encoded number.