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 / ravi saini

unsigned int count=0,no;
/*
Enter no Here................
*/
while(no ! =0)
{
if((no & 0x01) ==1)
count++;
no=no >>1
}
printf("%d",count);

Is This Answer Correct ?    9 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain how can I open a file so that other programs can update it at the same time?

599


How can I write a function analogous to scanf?

662


Is c call by value?

613


Explain what is #line used for?

613


How to write a code for reverse of string without using string functions?

1583






How do c compilers work?

615


What does the error message "DGROUP exceeds 64K" mean?

729


What does the && operator do in a program code?

702


What is meant by type casting?

633


What is spaghetti programming?

676


How do you define CONSTANT in C?

660


Do character constants represent numerical values?

848


What is array of structure in c?

606


Why is it usually a bad idea to use gets()? Suggest a workaround.

916


What is adt in c programming?

617