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
What is pointers in c?
Do array subscripts always start with zero?
what are bit fields? What is the use of bit fields in a structure declaration?
Compare and contrast compilers from interpreters.
Explain bitwise shift operators?
What is sizeof int?
What is main () in c?
which of the following shows the correct hierarchy of arithmetic operations in C a) (), **, * or/,+ or - b) (),**,*,/,+,- c) (),**,/,*,+,- d) (),/ or *,- or +
A banker has a seif with a cipher. Not to forget the cipher, he wants to write it coded as following: each digit to be replaced with the difference of 9 with the current digit. The banker chose a cipher. Decipher it knowing the cipher starts with a digit different than 9. I need to write a program that takes the cipher from the keyboard and prints the new cipher. I thought of the following: Take the input from the keyboard and put it into a string or an array. Go through the object with a for and for each digit other than the first, substract it from 9 and add it to another variable. Print the new variable. Theoretically I thought of it but I don't know much C. Could you give me any kind of hint, whether I am on the right track or not?
What are the 5 types of inheritance in c ++?
What is array in c with example?
Tell me when is a void pointer used?
What is the right type to use for boolean values in c?
Explain how can a program be made to print the name of a source file where an error occurs?
Explain why can’t constant values be used to define an array’s initial size?