write a program to find out number of on bits in a number?
Answer Posted / vivek
int setbit=1; //Lets start checking from first bit
int numBitSet=0; //Number of bits set in the number
while(setbit>0)
{
if(number&setbit) //bit wise and
numBitSet++;
setbit=setbit<<1;
}
| Is This Answer Correct ? | 23 Yes | 12 No |
Post New Answer View All Answers
Is c easy to learn?
What is the use of a conditional inclusion statement in C?
How to write a multi-statement macro?
which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above
What does %c do in c?
What is typeof in c?
What is bubble sort in c?
What type of function is main ()?
Explain how can I convert a number to a string?
Why isn't any of this standardized in c? Any real program has to do some of these things.
What is #error and use of it?
What is scope rule of function in c?
What is floating point constants?
What is difference between main and void main?
What does 3 periods mean in texting?