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 are header files? What are their uses?
class foo { public: static int func(const char*& p) const; }; This is illegal, why?
1.)how to find d most repeated word in a string? string ="how do you do"?? output should be do
1 Answers AAS, Nagarro, Vuram,
in case any function return float value we must declare a) the function must be declared as 'float' in main() as well b) the function automatically returned float values c) function before declared 'float' keyword d) all the above
State the difference between realloc and free.
what is the output on the screen? int n; n=printf("my name is %d",printf("kiran %d",printf("kumar"))); printf("\n %d \n",n);
How can you return multiple values from a function?
which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above
Can you subtract pointers from each other? Why would you?
How are portions of a program disabled in demo versions?
can we store values and addresses in the same array? explain
Explain what is a stream?