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 / venkat reddy

main()
{
int n,counter;
printf("enter a number");
scanf("%d",&n);// let n=5
while(n>0)
{
counter++;
n=n&(n-1);
}
printf("%d",counter);
getch();
}

Is This Answer Correct ?    11 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the scope of an external variable in c?

999


What is #define used for in c?

1027


Explain b+ tree?

1018


What is a wrapper function in c?

1084


What is difference between structure and union?

1091


What is && in c programming?

1125


Why is not a pointer null after calling free?

982


What is a macro, and explain how do you use it?

1033


What is .obj file in c?

1032


Explain argument and its types.

1011


How many levels of pointers have?

1003


What is the use of the function in c?

985


How do I convert a string to all upper or lower case?

1067


What is the best organizational structure?

1075


What are near, far and huge pointers?

1023