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

Why is it important to memset a variable, immediately after allocating memory to it ?

2000


how to execute a program using if else condition and the output should enter number and the number is odd only...

2207


Can i use “int” data type to store the value 32768? Why?

1144


What are compound statements?

1084


What are static variables in c?

1028


Write a program in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.

2167


Is the exit() function same as the return statement? Explain.

1036


What is c method?

941


Why main is used in c?

1010


What is difference between array and pointer in c?

1027


about c language

1961


What is .obj file in c?

1023


how do you execute a c program in unix.

1075


What is an identifier?

979


Q.1 write aprogram to stack using linklist o insert 40 items? Q.2 write a program to implement circular queue with help of linklist?

2042