inquiry about while loop

why does the programe output the last two numbers

5 1 respectively ??
they should be
1 1

????

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  #include<iostream>
using namespace std;
int main()
{
	int i=1;int j=1; int n=5;
	while(i<n)
	{
		int j=3;
		cout<<i<< " " <<j<< " ";
		++i;
		++j;
	}
	cout<<i<< "  "<<j<<" ";

	return 0;
}


1 3 2 3 3 3 4 3 5  1
The loop will keep running as long as i < n. When i becomes 5, i < n becomes false, and the loop stops.
when the loop stops ,, the program execute the next statement after the loop??
Yes, when the loop ends it will run the code that is after the loop.
when the loop stops ,, the program execute the next statement after the loop?
Yes it continues execution from firs statement after body of loop
thankss guyss
Topic archived. No new replies allowed.