Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What are the Advantages of using macro

1221


code for find determinent of amatrix

2021


What is pragma c?

1187


what is the function of pragma directive in c?

1183


How can I ensure that integer arithmetic doesnt overflow?

1259


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?

1338


What are the advantages of using Unions?

1172


What is the use of volatile?

1152


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

1324


Explain what is wrong with this statement? Myname = ?robin?;

1641


How can you avoid including a header more than once?

1025


c program for searching a student details among 10 student details

2144


How can you call a function, given its name as a string?

1209


Write a program which returns the first non repetitive character in the string?

1174


What are the types of bitwise operator?

1168