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 |
What is difference between the following 2 lines…. int temp = (int)(0x00); int temp = (0x00int);
What is the restrict keyword in C?
#define min((a),(b)) ((a)<(b))?(a):(b) main() { int i=0,a[20],*ptr; ptr=a; while(min(ptr++,&a[9])<&a[8]) i=i+1; printf("i=%d\n",i);}
write a program to generate 1st n fibonacci prime number
What is the mean of function?
how to print a statement in c without use of console statement ,with the help of if statement it should print
Why dont c comments nest?
Explain what is the benefit of using enum to declare a constant?
how to print 2-D array using a single for loop?
2 Answers Mind Tree, TCS, Value Labs,
Why do we use stdio h and conio h?
whether itis a structured language?
What is meant by realloc()?