#include #include using namespace std; int main() { cout << "I am thinking of a number in the range 1 to 10 inclusive.\n" << "Keep trying until you guess it.\n\n"; int correct {6}; //To mention i inside the parenthesis of the do-while loop, //i must be declared outside of the curly braces of the loop. int i {0}; do { cout << "Please type your guess: "; cin >> i; if (!cin) { cerr << "Sorry, that wasn't a number.\n"; return EXIT_FAILURE; } } while (i != correct); //means "i not equal to correct" //i is still alive here because it was created outside the loop. //At this point, i and correct are the same number. cout << "That's right, the number was " << correct << ".\n"; return EXIT_SUCCESS; }