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...

Function to find the given number is a power of 2 or not?

Answer Posted / sivaraj

Answer 2 Ms is correct and more efficient.

because if a number is power 2 it is in form

1000---->8
100----->4
10------>2 like form
subtract one from that and do with bitwise and it should be
zero.

ie 1000(8) & 0111(7)== 0

Is This Answer Correct ?    55 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between union All statement and Union?

1166


Explain what are bus errors, memory faults, and core dumps?

1319


Is r written in c?

1194


How can you access memory located at a certain address?

1166


How do I copy files?

1108


What is meant by operator precedence?

1210


Which control loop is recommended if you have to execute set of statements for fixed number of times?

1415


Can I use base-2 constants (something like 0b101010)? Is there a printf format for binary?

1065


Is exit(status) truly equivalent to returning the same status from main?

1123


Why is c called "mother" language?

1333


What is a constant and types of constants in c?

1178


What is oops c?

1348


What is array of structure in c?

1256


Write a Program to find whether the given number or string is palindrome.

1347


What are lookup tables in c?

1039