Give a method to count the number of ones in a 32 bit number?
Answer Posted / ataraxic
int i = 0;
while (x) {
x &= x-1;
++i;
};
printf("number of ones is %d\n", i);
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Which of these functions is safer to use : fgets(), gets()? Why?
Did c have any year 2000 problems?
Why doesnt that code work?
Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].
What is string function c?
When should a type cast not be used?
Is null equal to 0 in sql?
how to introdu5ce my self in serco
Why c is called free form language?
Sir i need notes for structure,functions,pointers in c language can you help me please
i = 25;switch (i) {case 25: printf("The value is 25 ");case 30: printf("The value is 30 "); When the above statements are executed the output will be : a) The value is 25 b) The value is 30 c) The value is 25 The value is 30 d) none
Explain modulus operator.
Is the exit() function same as the return statement? Explain.
5 Write an Algorithm to find the maximum and minimum items in a set of ānā element.
What is the difference between null pointer and wild pointer?