what is the purpose of the code, and is there any problem
with it.
bool f( uint n )
{ return (n & (n-1)) == 0; }
function returns if the number is a power of 2. if number value is 1, 2, 4, 8, 16 ... then TRUE is returned.
f(1) => 1 & 0 => 0001 & 0000 => 0
f(2) => 2 & 1 => 0010 & 0001 => 0
f(3) => 3 & 2 => 0011 & 0010 => 1 (non zero) => return true
f(4) => 4 & 3 => 0100 & 0011 => 0
f(5) => 5 & 4 => 0101 & 0100 => 4 (non zero) => return true
f(6) => 6 & 5 => 0110 & 0101 => 4 (non zero) => return true
f(7) => 7 & 6 => 0111 & 0110 => 6 (non zero) => return true
f(8) => 8 & 7 => 1000 & 0111 => 0
Is This Answer Correct ? | 1 Yes | 0 No |
Explain the term printf() and scanf() used in c language?
What is an lvalue?
write aprogram for There is a mobile keypad with numbers 0-9 and alphabets on it. take input of 7 keys and then form a word from the alphabets present on those keys.
1 Answers iGate, Shashi, Source Bits, Subex,
Why is c called a structured programming language?
Explain what is the difference between functions abs() and fabs()?
What is a buffer in c?
# define prod(a,b)=a*b main() { int x=2; int y=3; printf("%d",prod(x+2,y-10)); } the output of the program is a.8 b.6 c.7 d.none
control 50 devices which has 2 states on and off.using bitwise operator.plz answer it its urgent
code for concatination of 2 strings with out using library functions?
What is unary operator?
Differentiate between null and void pointers.
main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }