Chapter 9: Vectors and Arrays II

Chapter Goals

Arrays

Syntax 9.3: Array Variable Definition

type_name variable_name[size];
Example:
int scores[20];
Purpose: Define a new variable of an array type.

Array Parameters

Array Parameters (salarray.cpp)


Character Arrays

greeting[0]
greeting[1]
greeting[2]
greeting[3]
greeting[4]
greeting[5]
'H'
'e'
'l'
'l'
'o'
'\0'

Character Arrays (append.cpp)


Two-Dimensional Arrays

Syntax 9.4 : Two-Dimensional Array Definition

type_name variable_name[size1][size2];
Example:
double monthly_sales[NREGIONS][12];
Purpose: Define a new variable that is a two-dimensional array.

Two-Dimensional Arrays (matrix.cpp)