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...

Give a method to count the number of ones in a 32 bit number?

Answer Posted / ataraxic

int i = 0;

while (x) {
x &= x-1;
++i;
};

printf("number of ones is %d\n", i);

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does %p mean?

1158


Can one function call another?

1175


Is a pointer a kind of array?

1251


What is derived datatype in c?

1145


What is this infamous null pointer, anyway?

1109


What is #pragma statements?

1165


a direct address that identifies a location by means of its displacement from a base address or segment a) absolute address b) relative address c) relative mode d) absolute mode

1181


Which header file should you include if you are to develop a function which can accept variable number of arguments?

1467


In c programming, explain how do you insert quote characters (? And ?) Into the output screen?

1311


Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

1137


writ a program to compare using strcmp VIVA and viva with its output.

2087


What is a structure and why it is used?

1296


State the difference between x3 and x[3].

1171


What is a static variable in c?

1173


what do you mean by enumeration constant?

1067