write a program to find out number of on bits in a number?
Answer Posted / venkat reddy
main()
{
int n,counter;
printf("enter a number");
scanf("%d",&n);// let n=5
while(n>0)
{
counter++;
n=n&(n-1);
}
printf("%d",counter);
getch();
}
| Is This Answer Correct ? | 11 Yes | 2 No |
Post New Answer View All Answers
Can variables be declared anywhere in c?
What are external variables in c?
Write a programme using structure that create a record of students. The user allow to add a record and delete a record and also show the records in ascending order.
What are header files in c programming?
How do I swap bytes?
What is the concatenation operator?
What is c mainly used for?
What is meant by errors and debugging?
What is memcpy() function?
What is calloc in c?
This is a variation of the call_me function in the previous question:call_me (myvar)int *myvar;{ *myvar += 5; }The correct way to call this function from main() will be a) call_me(myvar) b) call_me(*myvar) c) call_me(&myvar) d) expanded memory
Why header files are used?
How can you allocate arrays or structures bigger than 64K?
In c programming language, how many parameters can be passed to a function ?
What is include directive in c?