write a program to find out number of on bits in a number?
Answer Posted / ajay vikram
void main()
{
int number,a=0,b,count=0;
printf("Enter the number : ");
scanf("%d",&number);
b = (number/2);
while(b)
{
if((number>>a)& 1)
{
count++;
}
a++;
b--;
}
printf("Number of ON Bits in the number : %d\n",count);
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
How many types of sorting are there in c?
How macro execution is faster than function ?
What does dm mean sexually?
Which one would you prefer - a macro or a function?
Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)
What is dynamic memory allocation?
What is the difference between break and continue?
What are the application of c?
What is volatile c?
What is the significance of scope resolution operator?
What are linked lists in c?
write a programming in c to find the sum of all elements in an array through function.
What is a structure member in c?
What are keywords in c with examples?
Tell me is null always defined as 0(zero)?