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 is the difference between NULL and NUL?
What is the right type to use for boolean values in c?
What is the purpose of macro in C language?
What does d mean?
How do you convert strings to numbers in C?
What is nested structure with example?
Which are low level languages?
What is "Duff's Device"?
What is #ifdef ? What is its application?
When should a far pointer be used?
Explain how can a program be made to print the line number where an error occurs?
What do you mean by keywords in c?
What is 'bus error'?
What is unary operator?
What are extern variables in c?