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

What is the most efficient way to count the number of bits
which are set in a value?

Answer Posted / pappu kumar sharma

int fnCntbts(int num )
{
int iCnt = 0;
while ( num )
{
num &= (num-1) ;
iCnt++;
}

return iCnt;

}

Is This Answer Correct ?    11 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is a function method?give example?

2309


What is pointer in c?

1140


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

1219


What is a sequential access file?

1091


What is infinite loop?

1027


What is meant by recursion?

994


Can you please explain the difference between exit() and _exit() function?

992


How do I swap bytes?

1022


What is 2 d array in c?

958


If one class contains another class as a member, in what order are the two class constructors called a) Constructor for the member class is called first b) Constructor for the member class is called second c) Only one of the constructors is called d) all of the above

997


What is binary tree in c?

1036


What is difference between stdio h and conio h?

1324


Simplify the program segment if X = B then C ← true else C ← false

2957


How many identifiers are there in c?

961


How is a null pointer different from a dangling pointer?

973