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

Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

1153


What does 1f stand for?

1086


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

2550


How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same

1052


How is null defined in c?

1100


What is function prototype in c language?

982


Why does not c have an exponentiation operator?

997


Hai,I have done with my bachelor of commerce and planing to ms,please suggest me how to convince vo for shifting from commerce to computers. Visa on 8 DEC 2014  Npu university

2003


What does s c mean on snapchat?

1037


What is the use of pointers in C?

1022


What is the use of in c?

943


Is there anything like an ifdef for typedefs?

1089


Why we not create function inside function.

2141


What is identifier in c?

963


If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?

1197