Random Number

//generate a random number between 1 & 100 that asks the user to guess what the number is
// if user's guess is higher than random number display "too high, try again"
// if user's guess is lower than the random number display "to low, try again"
// must use a loop that repeats until the user correctly guesses the random number or has made 10 guesses
// program to keep track of number of guesses the user makes
// must validate the user's guess by making sure the value entered in between 1 and 100,
// user should be told to make another guess
// the invalid input should not count as one of the 10 guesses the user is allowed
// less than 5 guesses "either you know the secret or you got lucky!"
// 5-7 guesses "you're pretty good at this!"
// 8-10 guesses "you'll do better next time."
// if guess 10 is not correct "sorry - you have taken too many guesses."

#include <iostream>
using namespace std;

int main()
{

Above is my instructions for a problem I was given, however in our book I wasn't given information on how to get a random number. At this point I am a little stuck on where to go from here if I can't get the random number portion of the program. Any help is much appreciated.
This article should be able to help you with how to randomize a random number. It helped me when I was unsure about making a randomized number.

Here is the link >> http://www.cplusplus.com/reference/cstdlib/rand/

Also, make sure when you initialize the random number you replace NULL with 0.
Otherwise you will not get a completely random number.

Hope this helps,
Torm04
Hint: Your probably going to have to use the srand() and rand() functions. Loop up how to use them. Also, you're going to have to create and int or something that will act as a counter (aka how many guesses the user tries).
Topic archived. No new replies allowed.