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 do graphics in c?
Can two or more operators such as and be combined in a single line of program code?
Why do we use int main?
Do you know the use of 'auto' keyword?
Why are some ANSI/ISO Standard library routines showing up as undefined, even though I've got an ANSI compiler?
What is c++ used for today?
How old is c programming language?
Should a function contain a return statement if it does not return a value?
a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion
What is the return type of sizeof?
What is pointer to pointer in c?
Which header file is used for clrscr?
What is the size of enum in c?
how logic is used
Why main is not a keyword in c?