random number between a range c++ code example
Example 1: c++ how to generate a random number in a range
min + ( std::rand() % ( max - min + 1 ) )
Example 2: cpp random number in range
int range = max - min + 1;
int num = rand() % range + min;
min + ( std::rand() % ( max - min + 1 ) )
int range = max - min + 1;
int num = rand() % range + min;