#include <iostream.h> // for cout and cin
#include <stdlib.h> // for srand and rand
#include <time.h> // to use the time function

void main()
{
	// declare and initialize variables
	int number;
	int guess;
	int tries;
	int minNumber;
	int maxNumber;

	// initialize each variable to a number so that garbage
	// is not stored in variable.
	minNumber = 1;
	maxNumber = 100;
	number = 0;
	guess = 0;
	tries = 0;
	
	srand((unsigned)time(NULL));
	number = (rand() % maxNumber) + minNumber;

	cout << "A number has been picked between " << minNumber << " and " << maxNumber << "." << endl;
	do
	{
		tries++;
		cout << "Guess #" << tries << ": ";
		cin >> guess;
		if (guess > number)
			cout << "Your guess was too high!" << endl;
		if (guess < number)
			cout << "Your guess was too low!" << endl;
	} while (guess != number);
	cout << "Congrats, you guessed the number in " << tries << " tries!" << endl; 
}