65.2k views
2 votes
The following statement number rand () % 5 + 10; assigns number a value in the range of 5 10. 0-15 O5-15. с 10-15. None of these

User Zekia
by
7.3k points

1 Answer

6 votes

Answer:

The following statement number rand () % 5 + 10; assigns number a value in the range of 5 to 15.

number = rand() % 5 + 10;

The rand() function returns a random integer in the range of [0, RAND_MAX). The % operator is the modulo operator, which returns the remainder of the division of its left operand by its right operand. In this case, the remainder of the division of a random integer in the range of [0, RAND_MAX) by 5 is in the range of [0, 4]. Adding 10 to this range gives us the range of [5, 14]. Therefore, the number variable will be assigned a value in the range of 5 to 15.

Step-by-step explanation:

User Eoin Murphy
by
8.3k points