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

write a program to find out number of on bits in a number?

Answer Posted / vivek

int setbit=1; //Lets start checking from first bit
int numBitSet=0; //Number of bits set in the number

while(setbit>0)
{

if(number&setbit) //bit wise and
numBitSet++;

setbit=setbit<<1;
}

Is This Answer Correct ?    23 Yes 12 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is c easy to learn?

1036


What is the use of a conditional inclusion statement in C?

1115


How to write a multi-statement macro?

1101


which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above

1784


What does %c do in c?

1053


What is typeof in c?

1064


What is bubble sort in c?

1104


What type of function is main ()?

1090


Explain how can I convert a number to a string?

1207


Why isn't any of this standardized in c? Any real program has to do some of these things.

1266


What is #error and use of it?

1349


What is scope rule of function in c?

1151


What is floating point constants?

1193


What is difference between main and void main?

1289


What does 3 periods mean in texting?

1135