Chapter 12 Two Dimensional Arrays
Chapter 12 Two Dimensional Arrays
Eighth Edition
Figure 12-1 Examples of items that use the two-dimensional array concept
© 2016 Cengage Learning®. May not be scanned, copied or
An Introduction to Programming with C++, Eighth Edition duplicated, or posted to a publicly accessible website, in 6
whole or in part.
Declaring and Initializing a Two-
Dimensional Array
• You must declare a two-dimensional array before you
use it
– As with one-dimensional arrays, it is good practice to
initialize the array variables
• Syntax for declaring a two-dimensional array:
dataType arrayName [numberOfRows] [numberOfColumns] =
{{initialValues}, {initialValues }, …{initialValues }};
• dataType specifies the data type of elements in the array
(all elements must have same data type)
• numberOfRows and numberOfColumns specify number of
rows and columns in array, respectively
Figure 12-7 IPO chart information and C++ instructions for the
Jenko Booksellers Program
© 2016 Cengage Learning®. May not be scanned, copied or
An Introduction to Programming with C++, Eighth Edition duplicated, or posted to a publicly accessible website, in 23
whole or in part.
Accumulating the Values Stored in
a Two-Dimensional Array (cont’d.)