BELOW MCQ GIVEN ANSWER CAN BE MORE THAN ONE OPTION. PLEASE PROVIDE CORRECT ANSWERS. ------------------- Q3 :- The ANSI C function below causes the program in which it runs to malfunction . Which of the following connection will help to perform function successfully ? /* Return a count of all the bits set in bytes */ int bitcount (unsigned char c) { unsigned char x , b , count =0; for (b = 0 , x= 1 ; !(x & 0x100); ++b, x <<=1) { if (x | c ) ++count; } return count; } A) change the type of x to a type larger than unsigned char. B) remove the extraneous variable b. C) change the return type to unsigned char . D) change if ( x | c) to if ( x & c) inside the for loop. E) change ! (c & 0x100) to ( x < 0x100) inside the for loop.
BELOW MCQ GIVEN ANSWER CAN BE MORE THAN ONE OPTION. PLEASE PROVIDE CORRECT ANSWERS.
-------------------
Q3 :- The ANSI C function below causes the program in which it runs to malfunction . Which of the following connection will help to perform function successfully ?
/* Return a count of all the bits set in bytes */
int bitcount (unsigned char c)
{
unsigned char x , b , count =0;
for (b = 0 , x= 1 ; !(x & 0x100); ++b, x <<=1) {
if (x | c )
++count;
}
return count;
}
A) change the type of x to a type larger than unsigned char.
B) remove the extraneous variable b.
C) change the return type to unsigned char .
D) change if ( x | c) to if ( x & c) inside the for loop.
E) change ! (c & 0x100) to ( x < 0x100) inside the for loop.
Step by step
Solved in 2 steps