ProgrammingHardProduct company OA
Assume 32-bit unsigned int. What is printed?
Assume 32-bit unsigned int. What is printed?
unsigned x = 0xABCD;
printf("%X %X", (x >> 4) & 0xF, (x & ~(0xFu << 8)) | (0x3u << 8));- A. C A3CD
- B. B A3CD
- C. C ABCD
- D. D A3CD
Correct answer: A. C A3CD
(x >> 4) & 0xF extracts the second nibble from the right, C. The mask ~(0xF << 8) clears bits 8 to 11 (the B), giving 0xA0CD, and OR-ing 0x300 writes 3 there: 0xA3CD. 'B' picks the third nibble instead.
More C Programming questions
- In C99, which declaration lets you allocate a rows × cols matrix of int (cols known at run time) with ONE malloc, use it as m[i][j], and…
- With 4-byte int, what is printed? c int a[4]; memset(a, 1, sizeof a); printf("%d", a[0]);
- What is printed? c struct N { int v; struct N nx; }; struct N c = {3, NULL}, b = {2, &c}, a = {1, &b}; struct N prev = NULL, cur = &a, nx…
- After this code, what does buf hold and what is n? c char buf[20]; int n = sprintf(buf, "%04d|%.2s", 7, "xyz");
- What is printed? c int c = 0; for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { if (j == i) continue; if (j > i + 1) break; c++…
- Which of the following is NOT allowed in C?