Thanks Zuk and everyone!
Now I am trying to limit the player to 3 guesses, but the IF ELSE's are looping for ever:-
Code:
#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std;
int main()
{
int human_guess = 0;
int guess_count = 0;
int random_integer;
srand((unsigned)time(0));
random_integer = (rand()%10);
cout << "Hi and welcome to the Guess the Number game.\nThe BLAH BLAH BLAH ur guess and then press Enter. Good luck! ";
while (guess_count < 3)
{
guess_count ++;
cin >> guess_count;
if (human_guess < random_integer)
{
cout << "Your guess was too low " << endl;
}
else if (human_guess > random_integer)
{
cout << "Your guess was too high" << endl;
}
else if (human_guess == random_integer)
{
cout << "You win! " << endl;
}
else if (human_guess < 1)
{
cout << "invalid guess, needs to be 1 or higher" << endl;
}
else if (human_guess > 10)
{
cout << "invalid guess, needs to be 10 or less" << endl;
}
else if (human_guess == 3)
{
cout << "you have ran out of guesses" << endl;
}
cin.get();
}
cin.get();
}
Could I get a point in the right direction please.
Many thanks