There are also two-dimensional arrays. Two-dimensional arrays are arrays whose elements are other arrays. Such arrays are very similar to tables, with rows and columns.
To declare such an array, one more pair of square brackets is required:
The picture shows an array with three elements, which are also arrays.
a...is the first element of the array;
a...is the second element;
a...is the third element.
An array that is an element of another array is called a nested array.
You can also access the elements of a nested array through indices and another pair of brackets:
Why specify the data type and size of an array? - So that the compiler knows how much memory needs to be allocated for your data, and do not forget - that the array must contain data of the same type!
To use arrays to the fullest, in the following lessons, we will study loops. With the help of loops, we can automate work with arrays, for example, display an array's elements in turn (or according to some specific algorithm), or write text to arrays. Why do we need text in arrays? - Find out in the next lesson!
What is the output of this code?
Select the correct answer
Everything was clear?