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 variable and explain rules to declare variable in c?

1104


how to construct a simulator keeping the logical boolean gates in c

2264


Take an MxN matrice from user and then sum upper diagonal in a variable and lower diagonal in a separate variables. Print the result

1913


C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions

1066


What is pointer in c?

1206


Where are local variables stored in c?

1049


What is queue in c?

1110


How can this be legal c?

1094


What is c preprocessor mean?

1324


Find MAXIMUM of three distinct integers using a single C statement

1072


What is a built-in function in C?

1617


What are the different types of control structures in programming?

1140


i have a written test for microland please give me test pattern

2740


What do you understand by friend-functions? How are they used?

1214


What is c method?

1007