Hey guys,
I have to create a program that guesses the user's age.
The user has to enter X, if the computer guessed the right age.
If they are younger than the guessed age, they are to type Y, and the program will keep looking for random numbers with the first guess as the max value.
So if the initial guess is g1.
If the user enter 'Y' the program will guess a second guess g2, where:
g2= rand() %g1 +1;
Now what happens if the user is older than the computer's initial guess?
what should i set g2 to be?
In short, what I wanna do is let the program find a random number between a non-zero minimum and a maximum.
it will be (rand() % (128 - g1 + 1)) + g1
I have added a couple of parentheses to show you order of operations. Because 2 * (2 + 2) isn't equal to 2 * 2 + 2