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

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

1136


What is c programing language?

1137


How can I read in an object file and jump to locations in it?

1072


What is the c language function prototype?

1143


Why is c known as a mother language?

1292


Difference between pass by reference and pass by value?

1214


1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. The Logic should be written in Data Structures?

2522


Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

1149


Explain high-order bytes.

1181


Which built-in library function can be used to match a patter from the string?

1349


What is the difference between array and pointer in c?

1232


What is the difference between variable declaration and variable definition in c?

1105


What are the two forms of #include directive?

1223


What are the ways to a null pointer can use in c programming language?

1197


How many bytes are occupied by near, far and huge pointers (dos)?

1220