how do u find out the number of 1's in the binary
representation of a decimal number without converting it
into binary(i mean without dividing by 2 and finding out
the remainder)? three lines of c code s there it
seems...can anyone help
Answer Posted / srsabariselvan
int main()
{
int n,i=0;
scanf("%d",&n);
while(n!=0)
{
if(n&01)
i++;
n>>=1;
}
printf("%d",i);
}
| Is This Answer Correct ? | 3 Yes | 2 No |
Post New Answer View All Answers
Is that possible to store 32768 in an int data type variable?
Explain the binary height balanced tree?
#include main() { int *p, *c, i; i = 5; p = (int*) (malloc(sizeof(i))); printf(" %d",*p); *p = 10; printf(" %d %d",i,*p); c = (int*) calloc(2); printf(" %d ",*c); }
When should I declare a function?
Is using exit() the same as using return?
Explain high-order bytes.
Can we initialize extern variable in c?
plz let me know how to become a telecom protocol tester. thank you.
Explain how do you use a pointer to a function?
What's the right way to use errno?
we need to calculating INCOME TAX for the person. The INCOME TAX is as follows:- First $10000/- of income : 4% tax Next $10000/- of income : 8% tax Next $10000/- of income : 11.5% tax above $10, 00,00/- : 15% tax What is the Solution of this Question ?
List the difference between a While & Do While loops?
int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above
Is it valid to address one element beyond the end of an array?
what are the program that using a two dimensional array that list the odd numbers and even numbers separately in a given 10 inputs values