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 / ram

#include<stdio.h>
void main()
{
int a,count=0;
printf("enter a");
scanf("%d",&a);
while(a>0)
{
if(a%2==1)
count++;
a=a>>1;
}
printf("no of on bits =%d ",count);
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is string in c language?

1251


Tell me what are bitwise shift operators?

1178


Can a variable be both const and volatile?

1192


Can you assign a different address to an array tag?

1213


What is #error and use of it?

1349


What is the use of typedef in c?

1083


How can I trap or ignore keyboard interrupts like control-c?

1117


which is conditional construct a) if statement b) switch statement c) while/for d) goto

1268


how to build a exercise findig min number of e heap with list imlemented?

2127


What is the size of empty structure in c?

1128


What is a null pointer in c?

1315


int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above

1391


what type of questions arrive in interview over c programming?

2083


Explain function?

1142


why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???

2028