Skip to main content

Program to Reverse Bits

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;
}


Comments

Popular posts from this blog

CAN INTERVIEW QUESTIONS

Qualifiers and Modifier in C

RTOS Real time operating system interview questions

CAN INTERVIEW QUESTIONS 2

What is UDS protocol

Memory mapping in c

TOP IOT PLATFORMS