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...

Give a method to count the number of ones in a 32 bit number?

Answer Posted / vignesh1988i

#include<stdio.h>
#include<conio.h>
void main()
{
unsigned i;
int j=0,count=0;;
printf("Enter the number :");
scanf("%ld",&i);
while(j<=31)
{
if(!(((i>>j)&1)^1))
count++;
j++;
}
printf("\nnumber of 1's in ur number is : %d",count);
getch();
}


thank u

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can you determine the size of an allocated portion of memory?

1313


What is struct node in c?

1076


Why doesnt that code work?

1183


Why do we need volatile in c?

1175


Function which gives a pointer to a binary trees const an integer value at each code, return function of all the nodes in binary tree.?

1073


What is switch in c?

1109


What is chain pointer in c?

1061


What is strcmp in c?

1126


What is the difference between volatile and const volatile?

990


how can I convert a string to a number?

1084


Can you mix old-style and new-style function syntax?

1102


Write a program that takes a 5 digit number and calculates 2 power that number and prints it(should not use big integers and exponential functions)

6876


Explain how can I open a file so that other programs can update it at the same time?

1120


What are the 5 elements of structure?

1084


What is ambagious result in C? explain with an example.

2638