2D Array HELP

I am new to C++ and i am working on making an array and i am having trouble wrapping my head around the for loops. If you can help explain why we use them in simple terms, that would be very helpful.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  int main() {
	
	char grid[10][10] = { { '|','|','|','|','|','|','|','|','|','|',},
						  { '|','|','|','|','|','|','|','|','|','|',},
						  { '|','|','|','|','|','|','|','|','|','|',},
						  {	'|','|','|','|','|','|','|','|','|','|',},
						  {	'|','|','|','|','|','|','|','|','|','|',},
						  {	'|','|','|','|','|','|','|','|','|','|',},
						  {	'|','|','|','|','|','|','|','|','|','|',},
						  {	'|','|','|','|','|','|','|','|','|','|',},
						  {	'|','|','|','|','|','|','|','|','|','|',},
						  {	'|','|','|','|','|','|','|','|','|','|' } };

	
	for (int row = 0; row < 10; row++) {


		for (int column = 0; column < 10; column++) {
			cout << grid[row][column];
		}
		cout << endl;
	}
	
	system("pause");
	return 0;

}
A good idea would be to trace the code. Get out a pen and paper, see how the variables 'row' and 'column' are changing and how the array gets printed.
Last edited on
Im not sure what you mean.
Topic archived. No new replies allowed.