412 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
1 answer
1
SSR17 asked Feb 29
204 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
2 votes
2 votes
1 answer
2
rupamsardar asked Aug 30, 2023
466 views
#include <stdio.h int f(int x) { if(x%2==0) { return f(f(x-1)); } else return (x++); } int main() { printf("%d",f(12)); ret...
5 votes
5 votes
2 answers
3
saurabh0709 asked Aug 1, 2023
1,136 views
What will be the output of the following code? _______ #include <stdio.h int main(){ char val=250; int ans; ans= val+ !val + ~val + ++val; printf("%d", ans); return 0; }
2 votes
2 votes
1 answer
4