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 the purpose of scanf() and printf() functions?
What does & mean in scanf?
Difference between macros and inline functions? Can a function be forced as inline?
0 Answers HAL, Honeywell, Zomato,
what is recursion in C
What is a memory leak in structures? How can we rectify that?
Explain the difference between exit() and _exit() function?
what is the difference between const char *p, char const *p, const char* const p
5 Answers Accenture, Aricent, CTS, Geometric Software, Point Cross, Verizon,
What is a lvalue
how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12
A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile
c programs are converted into machine language with the help of a) an interpreter b) a compiler c) an operatinf system d) none of the above
in C-programming language without using printf statement can we get output r not ? if yes how and if no also how ?