Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: An 8-bit unsigned counter starts at 250 and is incremented by 7 each step, wrapping modulo 256. How many increments until the counter first becomes less than 100 (counting the increment that makes it less than 100)?

  1. A. 2
  2. B. 0
  3. C. 1
  4. D. 3

Correct answer: C. 1

Simulate with wrap-around modulo 256 and stop when the value first drops below 100. Treating the counter as unbounded never triggers the wrap that matters here.

More Coding Interview Problems questions

Exams that ask this topic