Multiple choice general knowledge science & technology

In the formula used for generating random numbers within a specific range (int number = a + rand( ) % n;), the n represents?

  1. the first value in the range of numbers.

  2. the last value in the range of numbers.

  3. the number of terms in the range of numbers.

  4. the number of guesses the user will be allowed.

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

In the formula a + rand() % n, the modulo operation ensures the result ranges from 0 to n-1. So n represents the count of possible values. Adding a shifts the range to [a, a+n-1].