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 nested structure?
Print the foll in C...eg when n=5 the o/p must b + + + + + + + + + + + + + + + + +
Why are all header files not declared in every c program?
What is difference between static and global variable in c?
Write a program to generate prime factors of a given integer?
what is answer for perfect number????????????????
Write a program to find given number is even or odd without using any control statement.
What is the role of && operator in a program code?
c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above
write a proram to reverse the string using switch case?
what are the interview question's in the language c
related proverb of "dont count your chicken before it hatches"