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 / vaishu and hema

main()
{
int n,count=0,rem;
scanf("%d",&n);
while(n>0)
{
rem=n%2;
if(rem==1)
count++;
n=n/2;
}
printf("The number of on bits in the number is %d",count);
}

Is This Answer Correct ?    7 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I get random integers in a certain range?

1125


Can we add pointers together?

1115


Which header file is used for clrscr?

1106


Define macros.

1327


What does %2f mean in c?

1281


Why & is used in c?

1247


What is multidimensional arrays

1174


What is an expression?

1108


Can I use base-2 constants (something like 0b101010)? Is there a printf format for binary?

1055


Can true be a variable name in c?

1088


What is const keyword in c?

1218


Explain what is the benefit of using enum to declare a constant?

1130


Explain the bubble sort algorithm.

1113


A collection of functions,calls,subroutines or other data a) library b) header files c) set of files d) textfiles

1230


to find the closest pair

2370