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 / ajay vikram

void main()
{
int number,a=0,b,count=0;
printf("Enter the number : ");
scanf("%d",&number);
b = (number/2);
while(b)
{
if((number>>a)& 1)
{
count++;
}
a++;
b--;
}
printf("Number of ON Bits in the number : %d\n",count);
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between NULL and NUL?

1288


What is the right type to use for boolean values in c?

1028


What is the purpose of macro in C language?

1113


What does d mean?

1080


How do you convert strings to numbers in C?

1218


What is nested structure with example?

1067


Which are low level languages?

1089


What is "Duff's Device"?

1163


What is #ifdef ? What is its application?

1103


When should a far pointer be used?

1119


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

1204


What do you mean by keywords in c?

1141


What is 'bus error'?

1142


What is unary operator?

1097


What are extern variables in c?

991