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


Please Help Members By Posting Answers For Below Questions

#define MAX(x,y) (x) >(y)?(x):(y) main() { inti=10,j=5,k=0; k= MAX(i++,++j); printf("%d..%d..%d",i,j,k); }

774


What is far pointer in c?

805


What is a buffer in c?

568


any limit on the number of functions that might be present in a C program a) max 35 functions b) max 50 functions c) no limit d) none of the above

632


What are pointers? What are different types of pointers?

622






A collection of data with a given structure for excepting storing and providing on demand data for multiple users a) linked list b) datastructer c) database d) preprocessor

620


Read the following data in two different files File A: aaaaaaaadddddddd bbbbbbbbeeeeeeee ccccccccffffffff File B: 11111111 22222222 33333333 By using the above files print the following output or write it in the Other file as follows aaaaaaaa11111111dddddddd bbbbbbbb22222222eeeeeeee cccccccc33333333ffffffffffff

2238


What does the characters “r” and “w” mean when writing programs that will make use of files?

849


i have a written test for microland please give me test pattern

2177


How the c program is executed?

628


Without Computer networks, Computers will be half the use. Comment.

1867


Should I learn data structures in c or python?

576


How a string is stored in c?

583


What is extern keyword in c?

639


What are the different data types in C?

725