ProgrammingVery hardGATE CS · Campus placements
uint8_t x = 0x90; uint8_t y = x & (uint8_t)(x - 1); What is y?
- A. 0x90
- B. 0x8F
- C. 0x10
- D. 0x80
Correct answer: D. 0x80
x - 1 is 0x8F, and ANDing with 0x90 clears the lowest set bit, giving 0x80. This is the standard single-bit clear trick.
More C Programming questions
- int f(int n) { if (n == 0) return 0; return n % 2 + f(n / 2); } What is f(37)?
- For unsigned int i = 3; i >= 0; i--, what happens to the loop body?
- char a[] = "hi"; char b[] = "hi"; What does a == b evaluate to?
- What does printf("%d", '0' < '9') print?
- What does printf("%d", 6 % 4 2) print?
- Which expression computes ceil(a / b) for positive int a = 7 and b = 3 using integer arithmetic, written as ((a + b - 1) / b)?