Answer the question
In order to leave comments, you need to log in
How does the rand() function work?
I don’t understand what exactly the rand() function generates - why from 0 to rand_max, and why we set such a range.
a+rand()%(ba)
I don't understand why use the remainder of the division.
Answer the question
In order to leave comments, you need to log in
The function generates a pseudo-random number in the range [0, RAND_MAX), this is a given given in the documentation. The formula you gave is obviously getting a number in the range [a, b]. As for the inclusion of borders, however, I'm not sure ...
I don't understand what exactly the rand() function generates
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question