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
What is "Hungarian Notation"?
What is the use of linkage in c language?
Which is the memory area not included in C program? give the reason
Add Two Numbers Without Using the Addition Operator
Explain what happens if you free a pointer twice?
Which is better between malloc and calloc?
Explain threaded binary trees?
What does %d do?
What is size of union in c?
When should I declare a function?
Write a program to reverse a given number in c language?
Can a variable be both const and volatile?
What does 4d mean in c?
printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions
What is the purpose of void in c?