← All lectures

Lecture 14 · 30 min

Arrays — Lists of Values

A single name for many values of the same type, stored in contiguous memory and accessed by an integer index.

DeclarationIndexingInitializationInput/outputLinear searchCharacter arrays
Slide 1 / 16

The problem arrays solve

Imagine storing the marks of 100 students. Without arrays:

int mark1, mark2, mark3, ..., mark100;  // 100 variables!

With an array:

int marks[100];  // ONE name, 100 storage boxes

An array is a collection of items of the same data type, stored in consecutive memory locations, all accessed using one name and an index.

← / → navigateF fullscreenEsc exit⌘K search