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 the height of tree if leaf node is at level 3. please explain

2153


What are pointers? What are different types of pointers?

1149


How will you declare an array of three function pointers where each function receives two ints and returns a float?

1376


How can I rethow can I return a sequence of random numbers which dont repeat at all?

1192


What are the different categories of functions in c?

1138


What is array in C

1168


What is indirection? How many levels of pointers can you have?

1152


How can a string be converted to a number?

1023


List the difference between a While & Do While loops?

1112


What is the best way of making my program efficient?

1040


Write a program to print all permutations of a given string.

1201


Explain the properties of union.

1087


What are the features of c languages?

1107


Write a program of advanced Fibonacci series.

1155


what is the difference between 123 and 0123 in c?

1208