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
Does c have enums?
Is c still relevant?
Is stack a keyword in c?
What is pragma in c?
How to define structures? ·
How to Throw some light on the splay trees?
a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above
Differentiate call by value and call by reference?
What does return 1 means in c?
Write a program to reverse a given number in c language?
what is bit rate & baud rate? plz give wave forms
Which type of language is c?
c language interview questions & answer
Write a program to print factorial of given number using recursion?
what are the advanced features of functions a) function declaration and prototypes b) calling functions by value or by reference c) recursion d) all the above