I am trying to limit the number of guesses in this random number guessing program to 5. I have everything working except that it doesn't display the "you lost!" after 5 guesses. My code is below if anyone has any suggestions.
int main()
{
constexpr int MaxTries {5};
int guess {}, tries {};
std::srand(static_cast<unsigned int>(time(nullptr)));
const auto number {rand() % 50 + 1}; // number between 1 and 50
do {
std::cout << "Enter a guess between 1 and 50: ";
std::cin >> guess;
++tries;
if (guess < number)
std::cout << "Your guess is low\n";
else if (guess > number)
std::cout << "Your guess is high\n";
else
std::cout << "You guessed it right!!!\n";
} while (guess != number && tries != MaxTries);
if (guess != number)
std::cout << "You lost!!!\n";