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

write a program to find out number of on bits in a number?

Answer Posted / vivek

int setbit=1; //Lets start checking from first bit
int numBitSet=0; //Number of bits set in the number

while(setbit>0)
{

if(number&setbit) //bit wise and
numBitSet++;

setbit=setbit<<1;
}

Is This Answer Correct ?    23 Yes 12 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a c program to build a heap method using Pointer to function and pointer to structure ?

4695


Should I learn c before c++?

1237


Which is better malloc or calloc?

1105


What is function pointer c?

1120


What is 2c dna?

1083


Why functions are used in c?

1142


Here is a neat trick for checking whether two strings are equal

1022


How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same

1113


Write a program to check armstrong number in c?

1134


Which one would you prefer - a macro or a function?

1087


What is difference between far and near pointers?

1044


Explain how can you tell whether a program was compiled using c versus c++?

1105


What is a good way to implement complex numbers in c?

1053


How do you convert strings to numbers in C?

1230


Why is structure padding done in c?

1134