Two Dimensional Array

Write your question here.

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
  #include<iostream>
using namespace std;

int main()
{
	int matrix[2][3], row, col, maxrows = 2, maxcols = 3;
	// get values for the matrix
	for (row = 0; row < maxrows; row++)
	{
		for (col = 0; col < maxcols; col++)
		{
			cout << "Please enter a value for position[" << row << "," << col << "]";
			cin >> matrix[row][col];
		}
	}
	
	// Display The values of matrix
	cout << "The values entered for the matrix are:" << endl;
	for (row = 0; row < maxrows; row++)
	{
		for (col = 0; col < maxcols; col++)
		{
			cout << "\t" << matrix[row][col];
		}
		cout << endl; 
	}
}

my question is is pretty stupid but it confused me so i just thought to ask it here the line cin >> matrix[row][col]; is it reading the values in row and column on each repetition of the inner loop one by one or that the values just going to matrix array with the size of 2 and 3.
Last edited on
it reading the values in row and column on each repetition of the inner loop one by one.

Right.

read this ,

http://www.cplusplus.com/doc/tutorial/arrays/

hope this will help you to clear your doubts.
Last edited on
its a long read but i can follow it in some time thanks
Topic archived. No new replies allowed.