|
I don't get it
If I write this code(which outputs the numbers 1 to 10 and each number's square) it runs fine:
int counter = 1;
do
{
cout << counter << "\t" << counter * counter << endl;
}while(++counter <= 10)
As I said above it outputs 1 to 10 and each numbers square. But if I change the way I increment the control variable to counter++ so it looks like this:
int counter = 1;
do
{
cout << counter << "\t" << counter * counter << endl;
}while(counter++ <= 10)
It actually outputs all numbers plus and including 11 and it's square. I don't understand why that is. It seems to me that it shouldn't matter because either way when 10 gets incremented to 11 it should cause the test condition to fail, meaning the last number output should still be 10.
Please explain what's goin on here. I'm just a beginner(again).
|