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

console I/O functions means a) the I/O operations done on disk b) the I/O operations done in all parts c) the input given through keyboard is displayed VDU screen d) none of the above

1097


Why malloc is faster than calloc?

1017


Write a C program in Fibonacci series.

1049


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

2210


Explain why C language is procedural?

1168


How do you override a defined macro?

1209


Write a program on swapping (100, 50)

1068


What is structure of c program?

1082


I heard that you have to include stdio.h before calling printf. Why?

1010


What are static variables in c?

1031


What is pivot in c?

976


What does the error 'Null Pointer Assignment' mean and what causes this error?

1163


what are non standard function in c

1853


Write a code to generate a series where the next element is the sum of last k terms.

1173


What is difference between structure and union in c?

926