Bitwise Operators

Q1:
Which of the following statements are correct about the program?
#include<stdio.h>

int main()
{
    unsigned int num;
    int i;
    scanf('%u', &num);
    for(i=0; i<16; i++)
    {
        printf('%d', (num<<i & 1<<15)?1:0);
    }
    return 0;
}

A It prints all even bits from num

B It prints all odd bits from num

C It prints binary equivalent num

D Error

ANS:A - It prints all even bits from num

If we give input 4, it will print 00000000 00000100 ;

If we give input 3, it will print 00000000 00000011 ;

If we give input 511, it will print 00000001 11111111 ;



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.