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

Why is sprintf unsafe?

1086


What is the difference between mpi and openmp?

1308


Can we add pointers together?

1067


What is realloc in c?

1127


Explain data types & how many data types supported by c?

1089


What is time null in c?

1082


What’s a signal? Explain what do I use signals for?

1119


What is #define in c?

1055


What is meant by type specifiers?

1142


Why are all header files not declared in every c program?

1112


Explain the advantages of using macro in c language?

1006


Is there a way to switch on strings?

1096


write a program to print largest number of each row of a 2D array

2329


Find MAXIMUM of three distinct integers using a single C statement

1072


write a program to find the given number is prime or not

4778