How can I generate a random number from 300 to 700?

closed account (4wRjE3v7)
I've done codes before using this code:
secret = rand() % 100 + 1;

but how would I set it up so it only generates numbers from 300 to 700?

Thanks in advance!
rand()% 401 + 300;
You want a range of 401 numbers.
secret=rand()%401;
Will give you a number from 0 to 400.

Now bias it by 300.
secret +=300;

Or in a single statement:
 
secret=rand()%401 + 300;
Topic archived. No new replies allowed.