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

Find if a number is power of two or not?

Answer Posted / om

int f(int num)
{

if(( num>0) && (!(num & (num-1))) )
return 1;
else
return 0;
}
// f(16)...... 16 & 15 = 10000 & 01111 =00000
f(4) ...... 4 & 3 =0100 & 0111 =0000

f(11).......11 & 10 = 1011 & 1010 = 1010 so not...
f(12).......12 & 11 = 1100 & 1011 = 1000 so not...

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which is better oop or procedural?

1017


Which header file is used for clrscr?

1030


main use of recursive function a) processing speed high b) reduce program length/reduce repeated statements c) if you do not, use iterative methods like, for, while or do-while d) all the above

1063


What is the difference between a free-standing and a hosted environment?

1114


Explain what is wrong with this program statement? Void = 10;

1215


Write a c program to build a heap method using Pointer to function and pointer to structure ?

4648


how can i access hard disk address(physical address)? are we access hard disk by using far,near or huge pointer? if yes then please explain.....

1763


A float occupies 4 bytes in memory. How many bits are used to store exponent part? since we can have up to 38 number for exponent so 2 ki power 6 6, 6 bits will be used. If 6 bits are used why do not we have up to 64 numbers in exponent?

2289


What is structure packing in c?

1053


What is the hardest programming language?

1115


What is f'n in math?

1032


What math functions are available for integers? For floating point?

1102


What is the purpose of the preprocessor directive error?

1221


how to write a c program to print list of fruits in alpabetical order?

2269


Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)

1000