Read following C program and answer question 6 to 7 int func

Read following C program, and answer question 6) to 7)

int func( int x)

{

int count = 0;

while (x){

count++;

x = x & (x-1);

}

return count;

}

6) What value will be returned if the function call is func(14)

(a) 1

(b) 2

(c) 3

(d) None of above

7) What does the function func do?

(a) Count number of digits in a decimal number

(b) Count the number of 1s in the binary representation of a decimal number

(c) Count the number of 1s in a decimal number

(d) None of above

Solution

6) The value returned if the function call is func(14) is (c) 3

7) (b) Count the number of 1s in the binary representation of a decimal number

Read following C program, and answer question 6) to 7) int func( int x) { int count = 0; while (x){ count++; x = x & (x-1); } return count; } 6) What value

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site