   random numbers and max and min?
  Hi, i'm currently making a small program like the guess my number game, but in reverse rolls, where the user enters the number and the computer has to guess it. I've programed all of it but for one thing and that is sorting the minimum value out, my program basically seeds a random number and the user tell the computer whether the true number is less or greater that the guess value, if the true value is less that the guess the guess is set to the max value, the problem is setting the minimum value, i have it so that if the true value is greater than the guessed value, min becomes the guessed value, but i dont know how to get the random number to range between the min and max value i have it range to the max, dunno how to implement the min variable into the following line:cguess = rand() % max + 1Can anyone help, please.Thanks.   
Quote:Original post by Kain666i dont know how to get the random number to range between the min and max value i have it range to the max, dunno how to implement the min variable into the following line:cguess = rand() % max + 1To generate a random number between A and B, you need to generate a number between 0 and (B-A), and then add A to the result.int spread = (max+1) - min;cguess = rand() % spread + min;;  Thanks you, so much, It works perfectly now.Thanks again.   