ProgrammingVery hardGATE CS · Campus placements
uint32_t x = 0x80000001u; x = (x << 1) | (x >> 31); What is x?
- A. 0x00000003
- B. 0x00000002
- C. 0x80000001
- D. 0x00000001
Correct answer: A. 0x00000003
Shifting left drops the top bit and leaves 0x00000002. Shifting right by 31 brings that top bit back as bit 0, so the result is 0x00000003, a left rotation by one bit.
More C Programming questions
- unsigned char c = 0x7F; c = c 2 + 2; What is c?
- For the array {4, 1, 3}, how many index pairs i < j have a[i] > a[j]? These pairs are called inversions.
- How many binary strings of length 5 contain no two adjacent 1s?
- char s[] = "abc"; s[0] = 'x'; printf("%s", s); prints what?
- unsigned int n = 1u; unsigned int r = n << 31; What is r?
- int a = -7, b = 2; What is a / b b + a % b?