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 |
What is a class c rental property?
What is echo in c programming?
Two's compliment of -5
Explain how can I right-justify a string?
how to execute a program using if else condition and the output should enter number and the number is odd only...
What is the purpose of macro in C language?
What is an identifier?
Define VARIABLE?
2. What does static variable mean?
Write a c program for sum of first n terms of the series S = 1 - (1/3) + (1/5) -(1/7) + (1/9) ......
will the program compile? int i; scanf(ā%dā,i); printf(ā%dā,i);
What is strcpy() function?