Need help with my code its not stopping once the correct answer is given i don't know why please help...I'm using 25 as the seed and the answer is 62 but my code says 62 is too high ... thank you.
#include <iostream>
#include <cstdlib>
using namespace std;
int testTheGuess(int ,int);
int thinkUpNumber(int);
int main()
{
int x, guess;
cout << "Enter a seed for my Number: ";
cin >> x;
cout << x << "\n" << "I have a Number between 1 and 100.\n";
cout << "Can you guess my Number?\n";
thinkUpNumber(x);
cout << "Please enter your guess: ";
cin >> guess;
testTheGuess(guess, x);
return 0;
}
int thinkUpNumber( int seed)
{
int answer;
answer = rand();
srand(seed);
rand();
return answer;
}
int testTheGuess(int guess, int answer)
{
int count = 0;
while( guess != answer)
{
if( guess < answer)
{
cout << guess << " is to low.\n Try Again.\n\n";
}
else if( guess > answer )
{
cout << guess << " is to high.\nTry Again.\n\n";
}
else if( guess == answer )
{
cout << guess << " is correct.\nYou Must be lucky.\n\n";
}
else
{
cout << "Invaild input please try again\n";
}
cout << "please input another guess: ";
cin >> guess;
count++;
}
if( count < 10)
{
cout << "Good Job it only took you " << count << " times.\n\n";
}
else if( count > 10)
{
cout << "Uh oh took you " << count << " times.\n\n";
}
else
{
cout << "WOW";
}
return 0;
}