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

How many types of sorting are there in c?

1011


How macro execution is faster than function ?

1132


What does dm mean sexually?

1261


Which one would you prefer - a macro or a function?

1034


Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)

1217


What is dynamic memory allocation?

1283


What is the difference between break and continue?

1397


What are the application of c?

1044


What is volatile c?

959


What is the significance of scope resolution operator?

1347


What are linked lists in c?

1086


write a programming in c to find the sum of all elements in an array through function.

2115


What is a structure member in c?

956


What are keywords in c with examples?

1039


Tell me is null always defined as 0(zero)?

1034