Setting minimum in rand()

I'm working through some exercises on here. I'm doing the one that randomly guesses a number you choose. I need a way to set the lowest value generated.
I tried

x = rand() % 100 - x

x is the initial number guessed, so I figure if the user says that that number is too low, then it must be lower bound number. The range of numbers the user can choose is 1 to 100
 
x = rand() % (maximum - minimum) +minimum;
Note that with that code you will never get a random number that is equal to maximum. If you want to include maximum in the range we just need to make a small adjustment.
x = rand() % (maximum - minimum + 1) + minimum;
Topic archived. No new replies allowed.