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
Are the variables argc and argv are local to main?
What does char * * argv mean in c?
Describe wild pointers in c?
What does emoji p mean?
Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]
Describe how arrays can be passed to a user defined function
What is sizeof int in c?
What are qualifiers in c?
write a c program in such a way that if we enter the today date the output should be next day's date.
process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,
what is the diffrenet bettwen HTTP and internet protocol
What is the scope of static variable in c?
Explain About fork()?
How to draw the flowchart for structure programs?
What are Macros? What are its advantages and disadvantages?