Help understanding arrays.

How does a multidimensional array work? If I want to create a 2D array, does the computer view it? Does it view it as a straight line of characters, or does it save it as height by width
ex:
111111111111111111
vs
111111
111111
111111
Let's say you had an array named ArrayName. You then declare the size of the 2D array to be 9 and 8. The array would then look like ArrayName[9][8].

[9] indicates the "rows".

[8] indicates the "column".

So let's say you have the following values stored in a two-dimensional array:

1 2 3 4 5 6 7 8
2 3 4 5 6 7 8 9
3 4 5 6 7 8 9 0
4 5 6 7 8 9 0 1
5 6 7 8 9 0 1 2
6 7 8 9 0 1 2 3
7 8 9 0 1 2 3 4
8 9 0 1 2 3 4 5
9 0 1 2 3 4 5 6

The value ArrayName[9][8] will contain the value '5', since it's what is stored in the 9th row, 8th column.

Meanwhile, ArrayName[0][0] will contain the value '1'.

That is the simplest way I can explain it, coming from a fellow beginner.
Last edited on
Topic archived. No new replies allowed.