I am trying to make a game where it has the computer guess the number you pick and you tell it whether its to High (H) or to Low (L). I can't get this to loop can someone please explain why? Any help would be appreciated.
int main()
{
char answer;
char again = 'Y';
srand(static_cast < unsigned int >(time(0)));
int secretN=rand() % 10 +1; // random number seed generator
int tries= 0;
cout << " Pick a number between 1 and 10 and I will Guess it !" <<endl; // random number 1-100
cout << " is" << secretN <<" your secret number" <<" or is it to Higher or to Lower? > (H/L)" << endl;
cin >> answer;
++tries;
if (answer == 'H')
{
srand(static_cast < unsigned int >(time(0)));
int secretN=rand() % 10 - 2;
cout << " Too HIGH!!!" << endl;
cout << " Try again :)" << endl;
cout << " is " << secretN << " to High or to Low? > (H/L)" <<endl;
cin >> answer;
tries++;
}
if ( answer == 'L' )
{
srand(static_cast < unsigned int >(time(0)));
int secretN=rand() % 10 +1;
cout << " Too LOW!!!"<< endl;
cout << " Try again :)" << endl;
cout << " is " << secretN << " to High or to Low?> (H/L)" <<endl;
cin >> answer;
tries++;
}
if (answer == 'Y') {
cout << "I got it!" <<""<< " tries."<<tries << endl;
cout << "Would you like to try again"<<endl;
cin >> again;
again = 'Y';