1/20
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Array
A collection of data items, all of the same type, accessed using a common name.
One-dimensional array
An array that is like a list, where elements are accessed via a single index.
Two-dimensional array
An array that is like a table, where elements are accessed via two indices.
Vector
A one-dimensional array.
Matrix
A two-dimensional array.
Declaration of an array
dataType arrayName[arraySize];
Uninitialized arrays
Must have dimensions of their rows, columns, etc. listed within square brackets.
Array Index
A non-negative integer used to access elements of an array; starts from zero.
Initialize an array
To assign values to an array at the time of declaration using curly braces.
Accessing array elements
To retrieve or manipulate values in an array using indices.
Multidimensional array
An array that has more than one dimension, such as 2D or 3D.
Accessing 2D array elements
Use two subscripts, typically denoting row and column indices.
C++ array initialization
Arrays can be initialized at the time of declaration using brackets and values.
Array size
The number of elements an array can hold, which is fixed after declaration.
Common mistake with arrays
Forgetting that the first index starts at zero.
Floating-point array declaration
float mark[5]; // An array that can hold 5 floating-point values.
Example of a 3D array declaration
int threedim[5][10][4]; // A three-dimensional array.
Array of arrays
A way to conceptualize multidimensional arrays, where each element is an array.
Partial array initialization
Initializing some elements of an array while leaving others as zero.
Constant expressions for array dimensions
Dimensions used in C++ arrays must be positive integral constants or constant expressions.
Input and output of array elements
Using scanf and printf functions to take input and print elements of an array.