loops
Can anyone just explain to me why this loop produuces this outcome.
Outcome (bolded) j : 0 3 6 9
12
Outcome (bolded) i : 0 1 2 3
4
I never expected j to go beyond 10.why is like so.is j <= 10 ignored?
1 2 3 4 5 6 7 8
|
int i = 0, j = 0;
while ( j <= 10 )
{
j += 3;
i++;
}
cout << i ;
|
The while loop will only terminate when j > 10, and the first time that occurs is when j == 12.
thanks
Topic archived. No new replies allowed.