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
What is the scope of an external variable in c?
What is #define used for in c?
Explain b+ tree?
What is a wrapper function in c?
What is difference between structure and union?
What is && in c programming?
Why is not a pointer null after calling free?
What is a macro, and explain how do you use it?
What is .obj file in c?
Explain argument and its types.
How many levels of pointers have?
What is the use of the function in c?
How do I convert a string to all upper or lower case?
What is the best organizational structure?
What are near, far and huge pointers?