#include <iostream>
usingnamespace std;
int main()
{
for(int i = 0; i < 5; i++) // You have put a ; here which mean you have finish what in your for
cout << i;
return 0;
}
one more question: assuming I still have the ;
why is the value for i equal to 5, instead of four?
although the for loop ended, the for loop says that i < 5.
The for loop ends when the condition becomes false.
In this case, the first value of i which makes the condition i<5 false is i=5, so that's the value i ends up becoming afterwards.
In other words, for loops can't "anticipate" when they're going to end.