// TheAlphaNerd // The Basic Guessing game... wish me luck #include #include using namespace std; int main (void) { int secret, guess; // Initialize seed srand ( time(NULL) ); // generate secret number secret = rand() % 10 + 1; cout << "Guess The Secret Number and win a prize" << endl; cout << "Hint - it is a number between 0 and 10" << endl << endl; do{ cout << "Enter a number: "; // The following line accepts input from the keyboard into // variable input_var. // cin returns false if an input operation fails, that is, if // something other than an int (the type of input_var) is entered. if (!(cin >> guess)) { cin.clear(); cin.ignore(10000, '\n'); cout << "That was not a valid entry.... wessssley" << endl; // exit the do while loop } else if (guess < secret) { cout << "You Should try a bit higher" << endl; } else if (guess > secret) { cout << "You Should try a bit lower" << endl; } }while(guess != secret); cout << "Success!" << endl; return 0; }