Guessing Game

I am trying to create a c++ number guessing game. I need the program to be able to generate a random number between 1 and 100 and the user will guess it till he or she guesses the correct number. Ive never used a random number generator before but have read a little bit about them but still cant figure it out. All the info i have read on them displays the rand number and i dont want to display it as it will give the number away. How do i store the rand number till the user gets it right? Thanks.
You can declare a variable and store the random value there
srand ( time(NULL) );
int numbertoguess = (rand() % 100) + 1;
Last edited on
where do i put,

srand ( time(NULL) );
int numbertoguess = (rand() % 100) + 1;

at in my program?
in int main, before they guess the numbers. This is really basic, you should have at least put it in beginners.... perhaps you should read some more tutorials, especially on random numbers, before you ask any more questions.
Topic archived. No new replies allowed.