#### Question

Define a two-dimensional array of integers named grades. It should have 30 rows and 10 columns.

Verified

#### Step 1

1 of 3

As previously shown in the previous answers, one may want to define a collection of variables of the same data type. In that situation, declaring a variable for each item separately would $\textit{not be appropriate}$ because of the resulted $\textbf{headache}$ from dealing with each one $\textbf{individually}$; therefore, we introduce a collection of variables of the same data type---that is called an $\textbf{\textit{array}}$. The array is a collection of variables with the $\textit{same data type}$ that has the $\textbf{same name}$ used to reference the $\textit{whole bunch}$ of variables.

Nevertheless, one may, further, want to specify $\textbf{an array}$ for $\textit{each element}$, within the original array. We, in that situation, model $\textbf{two}$ types of relationship; assuming representing it as a $\textit{two-dimensional}$ collection, one that exists between $\textit{rows}$ of the array, and another one exists among the $\textit{columns}$ of that array.

For $\textbf{example}$, we may represent the deck of cards as a two-dimensional array where the columns represent $\textit{suits}$ and rows represent $\textit{ranks}$; in that case, the total number of cards would be $13 (\text{ranks}) * 4 (\text{suits}) = 52$

Before viewing the code, we must first specify some details.

• Array name: the name you would use the access and deal with the array as a whole.

$\texttt{grades}$ in the below code.

• Array columns' size: the number of columns would exist within your defined array.

$\texttt{COL\_SIZE}$ in the below code.

• Array rows' size: the number of rows would exist within your defined array.

$\texttt{ROW\_SIZE}$ in the below code.

• Array column's index (subscript): the index used to specify a prticular column within the array.

$\texttt{col}$ in the below code.

• Array row's index (subscript): the index used to specify a prticular row within the array.

$\texttt{row}$ in the below code.

There is an important note we should mention here. The $\textbf{range}$ of any $\textit{index}$ is $[0,(SIZE-1)]$ inclusively. The $\textit{first}$ item has an index 0, and, therefore, the $\textit{last}$ item has an index SIZE-1.

See the below code.

## Create an account to view solutions

#### Computer Organization and Design MIPS Edition: The Hardware/Software Interface

5th EditionDavid A. Patterson, John L. Hennessy
220 solutions

#### Starting Out with C++ from Control Structures to Objects

8th EditionGodfrey Muganda, Judy Walters, Tony Gaddis
1,294 solutions

#### Fundamentals of Database Systems

7th EditionRamez Elmasri, Shamkant B. Navathe
687 solutions

#### Introduction to Algorithms

3rd EditionCharles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen
726 solutions