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

Why pointers are used in c?

946


How can I make sure that my program is the only one accessing a file?

1192


Explain how can a program be made to print the name of a source file where an error occurs?

1134


What standard functions are available to manipulate strings?

1075


Explain function?

1034


Is printf a keyword?

1157


An organised method of depicting the use of an area of computer memory used to signify the uses for different parts of the memory a) swap b) extended memory c) memory map d) all of the above

1117


What type of function is main ()?

996


What is the size of enum in bytes?

1036


What are the different categories of functions in c?

1082


When should we use pointers in a c program?

1081


explain what is fifo?

1027


Can you write a programmer for FACTORIAL using recursion?

985


How can a program be made to print the line number where an error occurs?

1036


What is the use of pointers in C?

1023