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

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

Is This Answer Correct ?    15 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain why can’t constant values be used to define an array’s initial size?

1320


What is the difference between exit() and _exit() function?

1006


When is a void pointer used?

1196


What does the characters “r” and “w” mean when writing programs that will make use of files?

1432


What is the maximum no. of arguments that can be given in a command line in C.?

1097


Whats s or c mean?

963


Can include files be nested? How many levels deep can include files be nested?

1101


Can variables be declared anywhere in c?

1045


main use of recursive function a) processing speed high b) reduce program length/reduce repeated statements c) if you do not, use iterative methods like, for, while or do-while d) all the above

1056


What is a substring in c?

1004


Why do we use int main instead of void main in c?

1108


What is the difference between fread and fwrite function?

1047


#include main() { enum _tag{ left=10, right, front=100, back}; printf("left is %d, right is %d, front is %d, back is %d",left,right,front,back); }

1077


What is action and transformation in spark?

1094


How to Throw some light on the splay trees?

1017