#include <iostream>
#include <cstdlib>
#include <ctime>
usingnamespace std;
int main()
{
int randNumber;
int userNumber;
int answer;
char again = 'Y';
bool win = false;
unsigned seed = time(0);
srand(seed);
randNumber = 0 + rand() % 501;
cout << "I'm thinking of a number between 0 and 501. Do you want to guess what it is? (Y/N)" <<endl;
cin >> userNumber;
{
while (!win)
{
if (userNumber < randNumber)
{
cout << "Sorry, bud. You're number was out of range. You guessed too low, try again." << endl;
cin >> userNumber;
}
elseif (userNumber > randNumber)
{
cout << "Sorry, bud. You're number was out of range. You guess too high, try again." << endl;
cin >> userNumber;
cin.ignore();
}
else //winner
{
cout << "Yup, that was my number! We're done, you can leave now." << endl;
win = true;
}
}
}
cin.get();
return 0;
}