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
What does char * * argv mean in c?
Subtract Two Number Without Using Subtraction Operator
Difference between linking and loading?
What are compound statements?
Explain do array subscripts always start with zero?
a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f
Explain what does the format %10.2 mean when included in a printf statement?
why we wont use '&' sing in aceesing the string using scanf
What does == mean in texting?
Explain what is page thrashing?
Is c a great language, or what?
What is the size of a union variable?
What are the types of arrays in c?
What kind of structure is a house?
How can a number be converted to a string?