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
Why pointers are used in c?
How can I make sure that my program is the only one accessing a file?
Explain how can a program be made to print the name of a source file where an error occurs?
What standard functions are available to manipulate strings?
Explain function?
Is printf a keyword?
An organised method of depicting the use of an area of computer memory used to signify the uses for different parts of the memory a) swap b) extended memory c) memory map d) all of the above
What type of function is main ()?
What is the size of enum in bytes?
What are the different categories of functions in c?
When should we use pointers in a c program?
explain what is fifo?
Can you write a programmer for FACTORIAL using recursion?
How can a program be made to print the line number where an error occurs?
What is the use of pointers in C?