Search Menu


Introduction to Two-Dimensional Arrays

So far all the arrays that you have been exposed to in this tutorial have been one dimensional. The dimension of an array means the number of indices used to refer to one particular cell in the array. For a one-dimensional array this can be thought of as a cell's position in a list. For a two-dimensional array there is also a nice way to think of what the indices mean. You can think of the array as being a big spreadsheet where all of the locations have a particular row and column that uniquely identify them. By convention the first index is considered to be the row and the second number is considered to be the column number. As you can imagine, this structure also works well for modeling a board, such as a tic-tac-toe board, on a computer.

Figure %: Tic-tac-toe Board

In this topic we will also consider multi-dimensional arrays and show that you can choose to have arrays of any dimension that is useful for your task.