#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;


int main()
{
	int target, guess, rand_val, numb_guesses = 0;

	srand(time(0));
	rand_val = rand();
	target = rand_val%101;
	cout << "Target is " << target << endl;

	guess = -1;

	cout << "I'm thinking of a number from 0 to 100" << endl;

	while (guess != target)
	{

		cout << "What number am I thinking of?  ";
		cin >> guess;
		while (guess < 0 || guess > 100)
		{	
			cout << "Your guess must be from 0 to 100...guess again: ";
			cin >> guess;
		}

		numb_guesses++;

		if (guess < target)
		{
			cout << "Too low...try again..." << endl;
		}
		else if (guess > target)
		{
			cout << "Too high...try again..." << endl;
		}
		else
		{
			cout << "Correct...it took you " << numb_guesses << " guesses!" <<endl;
		}

	}

	return 0;
}