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 / 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 is it valid to address one element beyond the end of an array?

1222


Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?

1104


What is the importance of c in your views?

1176


What are the general description for loop statement and available loop types in c?

1130


Why is event driven programming or procedural programming, better within specific scenario?

2438


The file stdio.h, what does it contain?

1168


Write the syntax and purpose of a switch statement in C.

1109


What is the significance of scope resolution operator?

1417


What is the newline escape sequence?

1078


Where define directive used?

1098


Explain how can a program be made to print the name of a source file where an error occurs?

1198


What is data type long in c?

1078


What is hashing in c?

1165


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

1591


why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above

1085