#include using namespace std; int main() { int secret = 6; //secret number random int guess; //user's guess int i; //loop variable bool gotIt = false; //guessed right cout << "Welcome to the Guessing " "Game!\n"; //set up a loop for three times i = 0; while (i < 3 && !gotIt) //three times { cout << "Enter guess # " << i + 1; cin >> guess; if (guess == secret) { cout << "Great, you got it in " << i + 1; if (i + 1 == 1) cout << " try!"; else cout << " tries!"; gotIt = true; } //close if else if (i < 2) cout << "Sorry....try again!"; else cout << "Sorry....."; i++; //increment } return 0; }