ProgrammingVery hardGATE CS · Campus placements
uint32_t x = 0x12345678u; the 32-bit left rotation by 8 bits, written as (x << 8) | (x >> 24), gives what value?
- A. 0x34567812
- B. 0x78123456
- C. 0x12345678
- D. 0x56781234
Correct answer: A. 0x34567812
Rotating left by 8 moves the top byte 0x12 to the bottom, giving 0x34567812. The shift form is only defined for counts 1 to 31, so a rotation of 0 must be handled separately.
More C Programming questions
- What is the Hamming distance between a = 0b1011 and b = 0b0110, that is the number of bit positions where they differ?
- A uint32t x = 37 is rounded up to a power of two by this code: x--; x |= x >> 1; x |= x >> 2; x |= x >> 4; x |= x >> 8; x |= x >> 16; x++…
- int a = -7, m = 5; What is ((a % m) + m) % m, the non-negative residue of a modulo m?
- unsigned char c = 200; int r = (c c) >> 8; What is r?
- unsigned char c = 0xF0; printf("%d", ~c); prints what?
- int x = 7; int a = &x, b = &x; a ^= b; b ^= a; a ^= b; What is x afterwards?