ProgrammingHardGATE CS · TCS NQT
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
printf("%d", ~5 & 0xF);
}- A. 10
- B. 11
- C. -6
- D. 5
Correct answer: A. 10
~5 is -6, whose low four bits are 1010, so the mask gives 10. The value 11 comes from the bit pattern 1011 being read with the wrong mask.
More C Programming questions
- What is printed? c #include <stdio.h> int main(void) { unsigned char c = 254; int n = 0; while (++c) n++; printf("%d", n); }
- How many iterations does this binary search make to find 13 in the sorted array 0 to 15? Compute with the program. c #include <stdio.h>…
- n <= 10^5 values, each up to 10^9, must be summed. Which declaration is correct for the total?
- To test whether n = 10^12 is prime by trial division up to sqrt(n), which loop is correct?
- A middle index of a range [lo, hi] is needed for hi near INTMAX. Which expression is safe?
- A scanf loop reads integers until the end of input. Which loop is correct when the input may end with a non-numeric token?