What is the most efficient way to count the number of bits
which are set in a value?

Answer Posted / boomer

pseudo

int size is 32 bits...right?

for(i = 0 to 31)
{
count += (value & 1) //& = and oprator
shift left value
}

Is This Answer Correct ?    6 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

write a program to print the consecutive repeated character from the given string... input string is : hhhhjkutskkkkkggggj output should be like this: hhhhkkkkkgggg anyone help me...

1479


What is function and its example?

619


What is the size of enum in bytes?

576


Can one function call another?

619


What is the benefit of using const for declaring constants?

579






Which driver is a pure java driver

982


What is difference between far and near pointers?

597


What do you know about the use of bit field?

600


What is the use of the function in c?

592


Explain how can you tell whether a program was compiled using c versus c++?

569


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?

1561


What is pointers in c?

640


Write an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.

651


What is malloc calloc and realloc in c?

654


What are linked lists in c?

641