11
In a certain program, I need to generate a random value greater than 1000 (with a limit set by me to up to 5000 (maybe it’s still too high)). This unique code refers to a type of registration to be performed. After answering some doubts of rand() %
with a teacher, we come to this code: 1000 + rand() % rand()
.
Would it be enough for what I want? And how could I delimit it to up to 5000? This being the only part I could not implement.
I think it should be
1000 + rand() % 4000
but I haven’t tested.– Maniero