How to call the row?

Here is the example code.
Let say I want to call the first row in the table.
row 1 = {1,2,3,4,5,6,7,8}
I want to declare the row 1 to be in that form.
How do I type this in c++ code?
Can anyone help me?

1
2
3
4
5
6
7
int numberTable[ROWS][COLS] = 
{
	{1,2,3,4,5,6,7,8},
	{7,2,8,4,5,4,7,3},
	{9,9,7,4,9,9,8,7},
	{6,3,7,4,5,4,5,7}
};
I probably misunderstood the question. Here is an example on how to call a specific row in the table:

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

int main()
{
	int userSelect{ 0 };
	const int ROWS = 4;
	const int COLS = 8;
	int numberTable[ROWS][COLS] =
	{
		{ 1, 2, 3, 4, 5, 6, 7, 8 },
		{ 7, 2, 8, 4, 5, 4, 7, 3 },
		{ 9, 9, 7, 4, 9, 9, 8, 7 },
		{ 6, 3, 7, 4, 5, 4, 5, 7 }
	};

	cout << "Which Row would you select to see?" << endl;
	cin >> userSelect;

	for (int count = 0; count < COLS; count++)
		cout << numberTable[userSelect - 1][count] << " ";

	cout << endl;


	return 0;

}
Topic archived. No new replies allowed.