write a program to find out number of on bits in a number?
Answer Posted / vaishu and hema
main()
{
int n,count=0,rem;
scanf("%d",&n);
while(n>0)
{
rem=n%2;
if(rem==1)
count++;
n=n/2;
}
printf("The number of on bits in the number is %d",count);
}
| Is This Answer Correct ? | 7 Yes | 3 No |
Post New Answer View All Answers
How can I get random integers in a certain range?
Can we add pointers together?
Which header file is used for clrscr?
Define macros.
What does %2f mean in c?
Why & is used in c?
What is multidimensional arrays
What is an expression?
Can I use base-2 constants (something like 0b101010)? Is there a printf format for binary?
Can true be a variable name in c?
What is const keyword in c?
Explain what is the benefit of using enum to declare a constant?
Explain the bubble sort algorithm.
A collection of functions,calls,subroutines or other data a) library b) header files c) set of files d) textfiles
to find the closest pair