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 are the types of data structures in c?

1085


Why is sprintf unsafe?

1001


Do you have any idea about the use of "auto" keyword?

1052


Write a program to generate random numbers in c?

1053


Tell us the use of fflush() function in c language?

1089


How are strings stored in c?

977


Explain what is the difference between text files and binary files?

1100


What does typedef struct mean?

1046


By using C language input a date into it and if it is right?

1022


write a program to copy the string using switch case?

2846


Write a function that will take in a phone number and output all possible alphabetical combinations

1001


Explain what are multidimensional arrays?

1011


What is the use of #include in c?

1036


How to find a missed value, if you want to store 100 values in a 99 sized array?

1366


What is struct node in c?

1024