This cout << " You have run out of attempts!"; will only show if turncounter is greater than ten, but your code stops incrementing turncounter before it gets that high.
Ok, I have tried changing the number. both in the while loop condition and the attempts if statement and still having trouble. If I change the while condition to a high number, and turncounter > 10 if allows me to go to 12 tries still...
if I change the if statement to an = condition instead of greater, it prints immediately after the first try, no matter what.
Change the while loop to a for loop. It will make the code clearer.
After the loop, check whether turnCounter==10. If it does then the loop exited after 10 turns. If it doesn't, then the loop exited from the break statement because the user won the game.
1 2 3 4 5 6 7 8 9 10
for (turnCounter = 0; turnCounter < 10; ++turnCounter) {
....
if (user won) {
cout << "You win! It only took you " << turncounter << "tries \n";
break;
}
}
if (turnCounter == 10) {
cout << "You have run out of attempts\n";
}