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 a nested formula?
Are there any problems with performing mathematical operations on different variable types?
Explain 'bit masking'?
why arguments can generally be passed to functions a) sending the values of the arguments b) sending the addresses of the arguments c) a & b d) none of the above
Explain the difference between malloc() and calloc() in c?
What is optimization in c?
What does s c mean on snapchat?
Explain what is the difference between a string and an array?
How do you construct an increment statement or decrement statement in C?
Why are some ANSI/ISO Standard library routines showing up as undefined, even though I've got an ANSI compiler?
What is the purpose of void pointer?
What is the difference between fread buffer() and fwrite buffer()?
How can you increase the size of a statically allocated array?
Tell us bitwise shift operators?
What is function in c with example?