write a program to find out number of on bits in a number?
Answer Posted / kavitha
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 ? | 0 Yes | 1 No |
Post New Answer View All Answers
console I/O functions means a) the I/O operations done on disk b) the I/O operations done in all parts c) the input given through keyboard is displayed VDU screen d) none of the above
Why malloc is faster than calloc?
Write a C program in Fibonacci series.
how to execute a program using if else condition and the output should enter number and the number is odd only...
Explain why C language is procedural?
How do you override a defined macro?
Write a program on swapping (100, 50)
What is structure of c program?
I heard that you have to include stdio.h before calling printf. Why?
What are static variables in c?
What is pivot in c?
What does the error 'Null Pointer Assignment' mean and what causes this error?
what are non standard function in c
Write a code to generate a series where the next element is the sum of last k terms.
What is difference between structure and union in c?