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 a function method?give example?
What is pointer in c?
What are the difference between a free-standing and a hosted environment?
What is a sequential access file?
What is infinite loop?
What is meant by recursion?
Can you please explain the difference between exit() and _exit() function?
How do I swap bytes?
What is 2 d array in c?
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
What is binary tree in c?
What is difference between stdio h and conio h?
Simplify the program segment if X = B then C ← true else C ← false
How many identifiers are there in c?
How is a null pointer different from a dangling pointer?