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?

  1. A. 12345
  2. B. 3554416254
  3. C. 1103515245
  4. 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

Exams that ask this topic