ProgrammingHardInfosys · C
What is printed?
What is printed?
unsigned int x = 0xB4;
printf("%u %u", x & -x, x & (x - 1));- A. 4 176
- B. 4 180
- C. 1 176
- D. 2 176
Correct answer: A. 4 176
x & -x isolates the lowest set bit (0xB4 = 10110100, so 4); x & (x - 1) clears that bit, giving 0xB0 = 176.
More C Programming questions
- What is printed? Assume a C compiler where double is larger than float. c printf("%d %d %d", sizeof('a') == sizeof(int), sizeof(1.5f) ==…
- What is printed? c int m[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; int (p)[3] = m + 1; printf("%d %d %d", (p)[2], p[1][0], ((p - 1))[1]);
- What is printed? c int a[] = {5, 10, 15, 20}; int p = a; p++ += 3; (p)++; ++p; ++p = 2; printf("%d %d %d %d %d", a[0], a[1], a[2], a[3]…
- What is printed? c unsigned char a = 250, b = 10; printf("%d %d", (a + b) > 255, (unsigned char)(a + b));
- What is printed? c uint8t x = 0xA5; x = (x << 4) | (x >> 4); printf("%d %d", x, (uint8t)~x);
- 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; }…