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 New modifiers?
Write a c program for sum of first n terms of the series S = 1 - (1/3) + (1/5) -(1/7) + (1/9) ......
What is getche() function?
yogesh patil in dell
Are the variables argc and argv are local to main?
Why is sizeof () an operator and not a function?
What is "Duff's Device"?
main() { int a; a=++100; printf("%d",a); getch(); }
who is the father of c
Is there any restriction in how many arguments printf or scanf function can take? in which file in my c++ compiler i can see the code for implementation of these two functions??
Write a program to find the number of times that a given word(i.e. a short string) occurs in a sentence (i.e. a long string!). Read data from standard input. The first line is a single word, which is followed by general text on the second line. Read both up to a newline character, and insert a terminating null before processing. Typical output should be: The word is "the". The sentence is "the cat sat on the mat". The word occurs 2 times.
What is cohesion in c?