ProgrammingHardTCS NQT · Infosys
uint8_t m = 0x0F; uint8_t r = ~m; What is r?
- A. 0xF0
- B. 0x0F
- C. -16
- D. 0xFF
Correct answer: A. 0xF0
~m is computed on int after promotion, giving -16. Converting -16 to uint8_t is well defined and yields 256 - 16 = 240, which is 0xF0. Printing ~m directly as int would show -16.
More C Programming questions
- int a = -1; unsigned int b = 1u; What does if (a < b) evaluate to?
- int a = -7, b = 2; printf("%d %d", a / b, a % b); prints what?
- #define SQUARE(x) xx. What does printf("%d", SQUARE(2+3)) print?
- #define MAX(a,b) ((a)>(b)?(a):(b)). With int i = 7; int m = MAX(i++, 5); what are m and i afterwards?
- qsort is called on int arr[5] = {-7, 3, -2, 5, -4} with a comparator that returns (abs(a) > abs(b)) - (abs(a) < abs(b)) on the two…
- A qsort comparator is written as return (const int )a - (const int )b; Which statement is true?