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

What is pass by reference in c?

1192


Find MAXIMUM of three distinct integers using a single C statement

1073


Explain Function Pointer?

1187


What are the 4 types of programming language?

1137


What is your stream meaning?

1249


Explain bit masking in c?

1145


What is static function in c?

1126


What is use of #include in c?

1173


What are qualifiers?

1059


What happens if header file is included twice?

1155


What is formal argument?

1146


In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping

1521


What is extern c used for?

1069


What is double pointer in c?

1046


What are the c keywords?

1210