ProgrammingVery hardGATE CS · Campus placements
uint32_t x = 0u; x = 1103515245u * x + 12345u; is applied twice in a row, starting from x = 0. What is x after the second update, computed modulo 2^32?
- A. 12345
- B. 3554416254
- C. 1103515245
- D. 24690
Correct answer: B. 3554416254
After the first update x is 12345. The second update gives 1103515245 * 12345 + 12345, which wraps modulo 2^32 to 3554416254. This is the classic linear congruential generator, and its unsigned wraparound is well defined.
More C Programming questions
- How many permutations of 4 distinct items have no item in its original position?
- How many distinct strings can be formed by arranging the letters of AABB?
- How many disk moves does the optimal Tower of Hanoi solution need for 5 disks?
- How many binary strings of length 4 contain at least two adjacent 1s?
- How many subsets of {1, 2, ..., 10} have an even sum of elements? The empty set counts.
- The pairs (1,2), (3,5) and (2,5) are sorted by the second value descending, with ties broken by the first value ascending. Which pair…