I want the loop to stop when totalGuesses turn into 0. How do I do that? In the bottom code I added a break for this condition but the first time I run it. it breaks automatically.
Ignore the identation.
// A
if ( guess != number )
do {
// code
} while ( guess != number );
// B
while ( guess != number ) {
// code
}
Are these different?
1 2 3 4 5 6 7 8 9 10 11 12 13
// C
while ( guess != number ) {
cin>> guess;
--totalGuesses;
if (totalGuesses==0) break;
}
// D
while ( guess != number ) {
if (totalGuesses==0) break;
cin>> guess;
--totalGuesses;
}