Came across a question to reverse bits of an unsigned integer. Tried a different approach. However, I'm not very familiar with how bit-wise operators work. Can someone please point what is fundamentally wrong here?
unsigned int reverse(unsigned int A)
{
unsigned int c=0;
int a=0;
while(a < 32)
{
c = c << 1;
c = c | ( A & (1 << a) );
a++;
}
return c;