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

//plz let me know whether it is correct or not...bcoz am just beginner
#include<stdio.h>

void main()
{

int j=0,i=0xFFFFE,temp=1;
int count=0;


while(j<=(sizeof(int)*8-1))
{

if(i&temp)
count++;
temp=temp<<1;
j++;
}
printf("%d",count);

}

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

State two uses of pointers in C?

1053


Explain what does it mean when a pointer is used in an if statement?

1062


What are data types in c language?

1055


What is the difference between functions abs() and fabs()?

1151


Explain what is the difference between a free-standing and a hosted environment?

1182


write a program to rearrange the array such way that all even elements should come first and next come odd

2275


What is calloc malloc realloc in c?

1055


How many parameters should a function have?

1186


What is a lookup table in c?

1117


Explain b+ tree?

1063


how to build a exercise findig min number of e heap with list imlemented?

2075


Can I initialize unions?

1037


I have seen function declarations that look like this

1040


How can you avoid including a header more than once?

981


Declare the structure which contains the following members and write in C list of all students who score more than 75 marks. Roll No, Name, Father Name, Age, City, Marks.

1328