Program to Reverse Bits – 16 bits
int main( void )
{
int a= 0xFF00, i, rev=0;
for( i = 0; i < 16; ++i )
{
if( a & ( 1 << i ) )
{
rev |= ( 0x8000 >> i );
}
}
printf( “Input is 0x%04x\n”, a );
printf( “Reverse Bit Is 0x%04x\n”, rev );
return 0;
}
ALL ABOUT TECHNOLOGY,andthinker embedded tutorials and IOT tutorials ,interview questions
Comments