The rand() function generates a pseudo-random integer from 0 to RAND_MAX. This can be used to generate a random integer from 0 to N-1 by using the modulo operator %: rand() % N, where N is the desired number of possible values. code example
Example: c++ how to generate a random number in a range
min + ( std::rand() % ( max - min + 1 ) )