ProgrammingHardProduct company OA
Assume 32-bit unsigned int. What is printed?
Assume 32-bit unsigned int. What is printed?
unsigned x = 0x12345678;
printf("%X", (x >> 16) | (x << 16));- A. 12345678
- B. 56781234
- C. 5678
- D. 78563412
Correct answer: B. 56781234
x >> 16 brings the high half 0x1234 down, and x << 16 moves the low half 0x5678 up (the top bits fall off a 32-bit value). OR-ing swaps the two 16-bit halves: 0x56781234. '78563412' is a full byte reversal, a different operation.
More C Programming questions
- What is printed? c int ok(const char s, int d) { if (d < 0) return 0; if (!s) return d == 0; return ok(s + 1, d + (s == '(') - (s ==…
- What is printed? c int n = 1200, r = 0; while (n) { r = r 10 + n % 10; n /= 10; } printf("%d", r);
- What is printed? c enum { R = 4, W = 2, X = 1 }; int perm = R | X; perm |= W; perm &= ~R; perm ^= X; printf("%d %d", perm, (perm & W) != 0);
- What is printed? c printf("%d", 5["abcdef"] - 'a');
- What is printed? c const char s = ""; int n = 0; for (int i = 0; i < strlen(s) - 1; i++) { n++; if (n > 5) break; } printf("%d", n);
- What is printed? c int pm(int b, int e, int m) { if (e == 0) return 1 % m; int h = pm(b, e / 2, m); h = h h % m; return e % 2 ? h b % m…