OK so im trying to do a program that will guess your number you choose. You tell it either too high, or too low, and it continues to guess. If you say too high, the upper bound should be set to that last guessed value. Same goes for lower bound. But, this doesnt happen. I just continue to get the initial range of numbers.
If R is a random number in any range, R%X will be a random number in range [0; X)
If S is a random number in some range [A; B], S+Y will be a random number in range [A+Y; B+Y].
So, in rand()%x+y, x is the distance form lowest to highest value and y is the lowest value.
Your rand lines should be rand()%(upper-lower)+lower.