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 incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?
Is c pass by value or reference?
15.what is the disadvantage of using macros? 16.what is the self-referential structure? 17.can a union be self-referenced? 18.What is a pointer? 19.What is the Lvalue and Rvalue? 20.what is the difference between these initializations? 21.Char a[]=”string”; 22.Char *p=”literal”; 23.Does *p++ increment p, or what it points to?
Differentiate between ordinary variable and pointer in c.
What are the properties of union in c?
How to reverse a linked list
1 Answers Aricent, Fidelity, IBM, TCS,
C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions
What language is windows 1.0 written?
Why do we write return 0 in c?
Write a program for the following series: 1*3*5-2*4*6+3*5*7-4*6*8+.................up to nterms
What is quick sort in c?
Program to simulate second clock