// Marvyn De La Torre    CS1A    Chapter 5, P.298, #20
/**************************************************************
 * Play Random Number Guessing Game
 * This program generates a random number and asks the user to
 * guess the number until the correct number is entered.
 *
 * Input:
 * The user's guesses.
 *
 * Output:
 * A message indicating whether the guess is too high,
 * too low, or correct.
 **************************************************************/

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

int main()
{
    int randomNumber;
    int guess;

    srand(time(0));
    randomNumber = rand() % 100 + 1;

    cout << "Guess the random number from 1 to 100: ";
    cin >> guess;

    while (guess != randomNumber)
    {
        if (guess > randomNumber)
        {
            cout << "Too high, try again." << endl;
        }
        else
        {
            cout << "Too low, try again." << endl;
        }

        cout << "Enter your guess: ";
        cin >> guess;
    }

    cout << "Congratulations! You guessed the number." << endl;

    return 0;
}