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

#include<stdio.h>
#include<conio.h>
void main()
{
int n,cnt,rem
scanf("%d",&n);
cnt=0;
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 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is pass by reference in c?

1241


Do variables need to be initialized?

1113


Compare and contrast compilers from interpreters.

1183


Write the test cases for checking a variable having value in range -10.0 to +10.0?

2370


What is a shell structure examples?

1153


What is define c?

1156


What is operator precedence?

1282


How do you generate random numbers in C?

1246


Explain how can you check to see whether a symbol is defined?

1255


What is the use of getchar functions?

1232


What are the different properties of variable number of arguments?

1204


What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?

1547


what is use of malloc and calloc?

1954


How many types of functions are there in c?

1227


What library is sizeof in c?

1142