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

Explain 'bit masking'?

1089


How do I get a null pointer in my programs?

1115


What is the most efficient way to store flag values?

1192


Explain with the aid of an example why arrays of structures don’t provide an efficient representation when it comes to adding and deleting records internal to the array.

3153


what will be the output for the following main() { printf("hi" "hello"); }

11011


How can I insert or delete a line (or record) in the middle of a file?

1022


What are file streams?

1020


to print the salary of an employee according to follwing calculation: Allowances:HRA-20% of BASIC,DA-45% of BASIC,TA-10%. Deductions:EPF-8% of BASIC,LIC-Rs.200/-Prof.Tax:Rs.200/- create c language program?

2184


How macro execution is faster than function ?

1198


What is scanf_s in c?

1125


How can I run c program?

1179


in multiple branching construct "default" case is a) optional b) compulsarily c) it is not include in this construct d) none of the above

1059


string reverse using recursion

2472


How can I list all of the predefined identifiers?

986


Explain null pointer.

1121