I was searching for an algorithm to reverse the bits...

I found one and coded it in c++...will this work

Code:#include<iostream> using namespace std; int main() { unsigned int num; cin>>num; // Reverse the bits in this number. unsigned int temp = num; // temp will have the reversed bits of num. int i; char xxx[10]; for (i = (sizeof(num)*8-1); i; i--) { temp = temp | (num & 1); temp <<= 1; num >>= 1; } temp = temp | (num & 1); cout<<temp<<"final"; return 0; }