431 views

1 Answer

Best answer
2 votes
2 votes
suppose u have entered num as 11 (in binary it will be 0000000000001011)

<< is left shift operator and <<  i left shifts by i every time       & is bitwise and operator returns 1 if both bits are 1 else return 0

1<<15 means left shift 1 in binary to left side by 15 places so it will be

0000000000000001<<15 =100000000000000

now for i=0

0000000000001011<<0 & 1000000000000000 =0 (with or without  ? 1:0

for i=1

000......10110 &1000000000000000 =0 (with or without  ? 1:0

and so on till i becomes 12 then it will retuen 1 as their is 1 on msb on both side of & operator

then 0 then 1 then 1 so ans will be

0000000000001011

so actually enetered number will be shown in its equvt binary equivalent
selected by

Related questions

0 votes
0 votes
2 answers
1
Debargha Mitra Roy asked Apr 16
164 views
#include <stdio.h int main() { int a[3] = {1, 3, 5, 7, 9, 11}; int *ptr = a[0]; ptr += sizeof(int); printf("%d", *ptr); return 0; }(Assume size of int to be $2$ bytes.)T...
0 votes
0 votes
2 answers
3
Debargha Mitra Roy asked Apr 10
187 views
What is the output of the below code?#include <stdio.h void main() { static int var = 5; printf("%d ", var ); if (var) main(); }a. 1 2 3 4 5b. 1c. 5 4 3 2 1d. Error
2 votes
2 votes
1 answer
4
SSR17 asked Feb 29
298 views
#include <stdio.h int main() { int i = -1; int x = (unsigned char)i; printf("%d", x); return 0; }output is 255 , but please explain how