ProgrammingVery hard
unsigned char c = 0xF0; c |= 0x0F; c <<= 1; printf("%d", c); What is printed?
- A. 254
- B. 510
- C. 255
- D. 30
Correct answer: A. 254
c becomes 0xFF, then the shift is done in int and stored back into an unsigned char, giving 0x1FE mod 256 = 0xFE = 254.
More C Programming questions
- What is the value of 1u << 31 >> 31 in C?
- What is printed by printf("%d", 0x7FFFFFFF + 0);?
- What value is -x when x is 7 in two's complement, expressed as ~x + 1?
- What is the value of (unsigned short)(65535 + 1) on a platform where unsigned short is 16 bits?
- Which bit trick isolates the lowest set bit of an unsigned n?
- What is the parity of the number 0b1101011 (1 for odd count of set bits)?