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
How can you find the exact size of a data type in c?
What is an example of structure?
How are variables declared in c?
What is pointers in c?
What is scanf () in c?
Why malloc is faster than calloc?
Explain is it valid to address one element beyond the end of an array?
what are the program that using a two dimensional array that list the odd numbers and even numbers separately in a given 10 inputs values
Explain the difference between #include "..." And #include <...> In c?
Explain the bubble sort algorithm.
Explain how do you list a file’s date and time?
How can I invoke another program (a standalone executable, or an operating system command) from within a c program?
What is bash c?
What is the sizeof () operator?
Which is more efficient, a switch statement or an if else chain?