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

Given a valid 24 hour format time find the combination of the value and write a program ,do not hard the value and if any other inputs provided should work with the logic implemented Input: 11:30 Output: 13:10 Input: 18:25 Output: 21:58

1471


difference between native and cross compilers

2080


Explain how can you check to see whether a symbol is defined?

1085


What is the basic structure of c?

1010


The __________ attribute is used to announce variables based on definitions of columns in a table?

1132


1234554321 1234 4321 123 321 12 21 1 1 12 21 123 321 1234 4321 1234554321

3632


Difference between exit() and _exit() function?

1077


What is difference between scanf and gets?

1169


Can we change the value of constant variable in c?

1005


Explain how can I prevent another program from modifying part of a file that I am modifying?

1037


Find duplicates in a file containing 6 digit number (like uid) in O (n) time.

3183


If the size of int data type is two bytes, what is the range of signed int data type?

975


Why doesnt that code work?

1074


What is a list in c?

983


When should a type cast be used?

965