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

#include<stdio.h>
#include<conio.h>
void main()
{
int n,cnt,rem
scanf("%d",&n);
cnt=1;
while(n!=0)
{
rem=n%2;
n=n/2;
cnt++;
}
printf("number of bits of the number is = %d",cnt);
getch();
}

Is This Answer Correct ?    0 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How is a pointer variable declared?

1041


Why isn't it being handled properly?

1024


Give me the code of in-order recursive and non-recursive.

1339


What are enums in c?

1143


What are the properties of union in c?

1021


What does p mean in physics?

1004


What is the need of structure in c?

1073


what is the function of pragma directive in c?

1083


What is the best organizational structure?

1079


Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10

15755


What is an auto variable in c?

1182


How do you construct an increment statement or decrement statement in C?

1191


What are qualifiers?

993


Under what circumstances does a name clash occur?

1170


What is the difference between the expression “++a” and “a++”?

1188