Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Determine if a number is a power of 2 at O(1).

Answers were Sorted based on User's Feedback



Determine if a number is a power of 2 at O(1)...

Answer / hary

int Isnopowerof2(int n)
{
if (n & n-1)
return 0;
return 1;
}

Is This Answer Correct ?    15 Yes 0 No

Determine if a number is a power of 2 at O(1)...

Answer / srinu naik

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

Post New Answer

More C Interview Questions

What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?

0 Answers  


Is c pass by value or reference?

0 Answers  


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?

1 Answers  


Differentiate between ordinary variable and pointer in c.

0 Answers  


What are the properties of union in c?

0 Answers  


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

0 Answers  


What language is windows 1.0 written?

0 Answers  


Why do we write return 0 in c?

0 Answers  


Write a program for the following series: 1*3*5-2*4*6+3*5*7-4*6*8+.................up to nterms

5 Answers   Convex Digital,


What is quick sort in c?

0 Answers  


Program to simulate second clock

2 Answers  


Categories