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 can I write a function analogous to scanf?

1191


What is the general form of function in c?

1022


Explain 'far' and 'near' pointers in c.

1147


What is volatile variable in c?

1099


the question is that what you have been doing all these periods (one year gap)

2092


List the different types of c tokens?

1076


A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference

1111


Why is c still so popular?

1051


Which one to choose from 'initialization lists' or 'assignment', for the use in the constructor?

1091


Why is c called c not d or e?

1104


Where is c used?

1101


What is volatile c?

1025


Which is better malloc or calloc?

1110


Explain the properties of union. What is the size of a union variable

1190


Can a variable be both const and volatile?

1139