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 / kavitha

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 ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can you find the exact size of a data type in c?

1046


What is an example of structure?

1101


How are variables declared in c?

1151


What is pointers in c?

1167


What is scanf () in c?

1172


Why malloc is faster than calloc?

1121


Explain is it valid to address one element beyond the end of an array?

1250


what are the program that using a two dimensional array that list the odd numbers and even numbers separately in a given 10 inputs values

1757


Explain the difference between #include "..." And #include <...> In c?

1092


Explain the bubble sort algorithm.

1113


Explain how do you list a file’s date and time?

1091


How can I invoke another program (a standalone executable, or an operating system command) from within a c program?

1264


What is bash c?

1065


What is the sizeof () operator?

1134


Which is more efficient, a switch statement or an if else chain?

1081