I need of help on very basic question

How can I start on a new line after each time the nested loop is terminated? To clarify, I mean each time the nested loop is finished and the outside loop starts again, not on every output.

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
using namespace std;
int main(){
	int x;
	int y;
	cin>>x;
	cin>>y;
	for (int i = 1; i<=x; i++) {
		for (int h =1; h<=y; h++) {
		cout<<i;
	}
}
}
Last edited on
Do a cout << endl; after the inner loop finishes:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
using namespace std;
int main() 
{	int x;
	int y;
	cin >> x;
	cin >> y;
	for (int i = 1; i <= x; i++) 
	{	for (int h = 1; h <= y; h++) 
		{	cout << i;
		}
	        cout << endl;
	}
}

Topic archived. No new replies allowed.