ProgrammingVery hardWipro NLTH · C · Advanced
What is printed?
What is printed?
uint8_t x = 0xA5;
x = (x << 4) | (x >> 4);
printf("%d %d", x, (uint8_t)~x);- A. 165 90
- B. 90 -91
- C. 2650 165
- D. 90 165
Correct answer: D. 90 165
The int result 0xA5A is truncated to 8 bits, 0x5A = 90 (a nibble swap); ~x is computed on the promoted int and the cast keeps the low byte, 0xA5 = 165.
More C Programming questions
- What is printed? c int add(int a, int b) { return a + b; } int sub(int a, int b) { return a - b; } int mul(int a, int b) { return a b; }…
- What is printed? c struct N { int v; struct N nx; }; int main(void) { struct N c = {3, 0}, b = {2, &c}, a = {1, &b}; struct N p = &a…
- What is printed? Assume C99 or later. c int g(int a, int b) { return b ? g(b, a % b) : a; } int main(void) { printf("%d %d", g(-48, 18)…
- What is printed? c #define MAX(a, b) ((a) > (b) ? (a) : (b)) int main(void) { int i = 3, j = 1; int m = MAX(i++, j++); printf("%d %d %d"…
- In C, sizeof(char) is:
- Which storage class makes a local variable keep its value between calls to the function?