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

how do u find out the number of 1's in the binary
representation of a decimal number without converting it
into binary(i mean without dividing by 2 and finding out
the remainder)? three lines of c code s there it
seems...can anyone help

Answer Posted / srsabariselvan

int main()
{
int n,i=0;
scanf("%d",&n);
while(n!=0)
{
if(n&01)
i++;
n>>=1;
}
printf("%d",i);
}

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

One of the Institutes contains 5 student groups. Every group contains 4 students. Institute wants to store student group’s details in array. Group should contain group member’s details (name and registration number and age), project name, and mark of the group.

2634


Can a local variable be volatile in c?

980


The number of measuring units from an arbitarary starting point in a record,area,or control block to some other point a) recording pointer b) offset c) branching d) none

1233


What is break in c?

1017


What is sizeof array?

1041


What is the difference between fread buffer() and fwrite buffer()?

1160


Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?

1048


What is array in C

1140


Can you apply link and association interchangeably?

1113


What is static volatile in c?

1011


void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }

1708


What is structure in c explain with example?

1147


Explain what is meant by 'bit masking'?

1183


What is a shell structure examples?

1076


Why & is used in scanf in c?

1085