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
What is the right way to use errno?
what is the height of tree if leaf node is at level 3. please explain
Why is extern used in c?
Explain main function in c?
What is typedef?
Why main function is special give two reasons?
Why dont c comments nest?
Given a valid 24 hour format time find the combination of the value and write a program ,do not hard the value and if any other inputs provided should work with the logic implemented Input: 11:30 Output: 13:10 Input: 18:25 Output: 21:58
What is the difference between int main and void main?
What is floating point constants?
What is the ANSI C Standard?
How do we make a global variable accessible across files? Explain the extern keyword?
What is pre-emptive data structure and explain it with example?
What is a node in c?
How do I convert a string to all upper or lower case?