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 does char * * argv mean in c?

1013


Subtract Two Number Without Using Subtraction Operator

795


Difference between linking and loading?

1068


What are compound statements?

1097


Explain do array subscripts always start with zero?

1193


a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f

2102


Explain what does the format %10.2 mean when included in a printf statement?

1301


why we wont use '&' sing in aceesing the string using scanf

2325


What does == mean in texting?

1233


Explain what is page thrashing?

1056


Is c a great language, or what?

1065


What is the size of a union variable?

1012


What are the types of arrays in c?

1112


What kind of structure is a house?

1004


How can a number be converted to a string?

1259