OK, most likely, it will be marked as duplicated, but I am looking for an answer and can not find something like that. The question arises: I want to generate random numbers in a certain range [t. min_value to max_value] and with a specific step. For the first part, the answer is:
int random_value = rand() % max_value + min_value;
How can I identify it? I believe the above solution leads to step 1. Is this correct? And if, for example, I want to generate numbers in steps of 2 (for example, 2, 4, ..., 16), what should I do?
source share