Demo program for using bitwise RIGHT SHIFT operator and bitwise AND operator in a C program:
What is the output of below c program?
assume that int is 4 bytes in this system.
void fun(int );
int c = 15;
void fun(int i)
for (int m = 31; m >= 0; m--)
int k = i >> m;
if (k & 1)
it prints binary equivalent of 15
it prints 0's for 32 times.
it prints 1's 32 times.
it prints 0 & 1 each for 16 times in one by one order.
this is the logic to generate binary equivalent of a given integer value. so it prints binary equivalent of 15.
Back To Top