write a program to find out number of on bits in a number?
Answer Posted / ram
#include<stdio.h>
void main()
{
int a,count=0;
printf("enter a");
scanf("%d",&a);
while(a>0)
{
if(a%2==1)
count++;
a=a>>1;
}
printf("no of on bits =%d ",count);
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is string in c language?
Tell me what are bitwise shift operators?
Can a variable be both const and volatile?
Can you assign a different address to an array tag?
What is #error and use of it?
What is the use of typedef in c?
How can I trap or ignore keyboard interrupts like control-c?
which is conditional construct a) if statement b) switch statement c) while/for d) goto
how to build a exercise findig min number of e heap with list imlemented?
What is the size of empty structure in c?
What is a null pointer in c?
int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above
what type of questions arrive in interview over c programming?
Explain function?
why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???