ProgrammingHardGATE CS · Campus placements
uint16_t x = 0x0F00; uint16_t y = x & (uint16_t)(0u - x); What is y?
- A. 0x0001
- B. 0x00F0
- C. 0x0100
- D. 0x0F00
Correct answer: C. 0x0100
The lowest set bit of 0x0F00 is bit 8, value 0x0100. The negation is taken as unsigned and then truncated to uint16_t, so the mask keeps only that bit.
More C Programming questions
- int a[] = {2, 4, 6, 8}; int p = a + 3, q = a; What does printf("%td", p - q) print?
- char names[3][5] = {"ab", "cde", "f"}; What is strlen(names[1]) + sizeof names[2]?
- A recursive function sums decimal digits: int ds(int n) { return n < 10 ? n : n % 10 + ds(n / 10); }. What is ds(98765)?
- How many 1 bits does 0xDEADBEEF have in binary?
- uint32t value = (uint32t)-1; printf("%d", value == 0xFFFFFFFFu); What is printed?
- How many index pairs i < j in the array {3, 5, 3, 5, 7} satisfy a[i] XOR a[j] == 0?