I have most of this code figured out, but my professor wants us to include a counter. Here is the pseudocode:
Assign counter 10
While counter is greater than zero
Display "You should study loops carefully."
Display the value stored in the counter
Decrement the couunter
Endwhile
I took that to mean:
1 2 3 4 5 6 7 8 9
counter = 10;
while (counter > 0)
{
cout << "\nYou should study loops carefully.";
cout << counter;
++counter;
}
pause ();
return 0;
As you might be able to tell right away, the display begins counting "You should study loops carefully." many times with the counter next to it. If I remove line 6 then the display never reads no matter what I input. This isn't quite an infinite loop, but I don't think he wants this. My guess is I need to tinker with line 6 some more, but I'm out of ideas.
The rest of my while function looks great, but this last part is giving me fits.
the ++counter increase the value first and then value is used.
in this case the value of counter will remain greater than 0 so it running infinite loop.