I have a simple nested while loop situation but I'm not sure how to increment numGuesses inside the second loop to escape the first loop once it is no longer less than 5.
while(numGuesses<5){
while(!correct){
cout << "\nGuess the number the computer randomply picked between 1 - 100: ";
numGuesses++;
cin >> guess;
if(guess<number){
cin.clear(); //clears input stream
cin.ignore(256, '\n');
cout << "\nSorry, your guess is too low";
}
else if (guess>number){
cout << "\nSorry, your guess is too high";
}
else{
cout << "\nYou guessed right, you win!";
correct = !correct;
}
}
}
cout << "Sorry, you lost. The number is: " << number;
Each time the inner while loop iterates I would like numGuesses to increase but I'm guessing its not in its scope?