Simple C++ Question

I need help understanding something simple.

How many times does the following loop execute, and what is its output ?

count = 1;
while ( count<= 12)
{
cout << count << endl;
cout++;
}

If someone could explain this I would greatly appreciate it. Thank you !
Last edited on
cout++;?
http://www.cplusplus.com/reference/ostream/ostream/
ostream has no operator++ defined.

Surely OP meant to write count++;

Would this make more sense, OP: for(int count = 1; count <= 12; count++)?

The loop is going from count = 1 through 12. Or 1 to 13. Either way you word, it will fail on count = 13.
Count
1
2
3
4
5
6
7
8
9
10
11
12 <-- Last output.
13 <-- Fails here. Exits loop.
Last edited on
Thanx for the help biscuit !
@ResidentBiscuit what would operator+ have to do with the post increment operator?
Typo. Forgot a +.
Topic archived. No new replies allowed.