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
What are the Advantages of using macro
code for find determinent of amatrix
What is pragma c?
what is the function of pragma directive in c?
How can I ensure that integer arithmetic doesnt overflow?
When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?
What are the advantages of using Unions?
What is the use of volatile?
c programs are converted into machine language with the help of a) an interpreter b) a compiler c) an operatinf system d) none of the above
Explain what is wrong with this statement? Myname = ?robin?;
How can you avoid including a header more than once?
c program for searching a student details among 10 student details
How can you call a function, given its name as a string?
Write a program which returns the first non repetitive character in the string?
What are the types of bitwise operator?