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 the basic structure of c?
Can stdout be forced to print somewhere other than the screen?
What is the Purpose of 'extern' keyword in a function declaration?
What is static memory allocation? Explain
What is a scope resolution operator in c?
What is this infamous null pointer, anyway?
what is a function method?give example?
If fflush wont work, what can I use to flush input?
A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(
an expression contains relational operators, assignment operators, and arithmatic operstors. In the absence of parentheses, they will be evaluated in which of the following order a) assignment, relational, arithematic b) arithematic, relational, assignment c) relational, arithematic, assignment d) assignment, arithematic, relational
How can I recover the file name given an open stream or file descriptor?
What are the advantages of using linked list for tree construction?
What is #ifdef ? What is its application?
Take an MxN matrice from user and then sum upper diagonal in a variable and lower diagonal in a separate variables. Print the result
the real constant in c can be expressed in which of the following forms a) fractional form only b) exponential form only c) ascii form only d) both a and b