Learn to Program with ZedLX

Free Online Programming Course for Beginners

Arrays [2/11]

The elements of an array can be accessed using the index operator. The index operator is [], as shown in the example program.

The argument of the index operator [] is called an index. In the case of arrays, an index is an expression which must always be of type int .

Remember that the index must always be an integer value, which is why the last line is commented out - attempting to use a non-integer value as an index would result in an error.

Loading...