Determine if a number is a power of 2 at O(1).
Answers were Sorted based on User's Feedback
Answer / hary
int Isnopowerof2(int n)
{
if (n & n-1)
return 0;
return 1;
}
Is This Answer Correct ? | 15 Yes | 0 No |
if((~n+1)& n ==n) printf("\n Given number is power of 2");
else printf("\Not the POwer of 2");
Is This Answer Correct ? | 1 Yes | 0 No |
while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above
Write code for finding depth of tree
What is a string?
Explain what is the benefit of using #define to declare a constant?
application of static variables in real time
How can I call system when parameters (filenames, etc.) Of the executed command arent known until run time?
Write a program to swap two numbers without using third variable in c?
please send me papers for Dy. manager IT , PNB. it would be a great help for me.
What is the 'named constructor idiom'?
What does sizeof function do?
pascal triangle program
If I have a char * variable pointing to the name of a function ..