Chapter 7 Arrays Flashcards
7.1 Arrays can hold ____ _____.
Multiple values
7.1 How are the values in arrays stored?
The values are stored together in consecutive memory locations.
7.1 int days[6];
This is a definition of an array of integers.
7.1 How many elements can this array store?
int days[6];
6
7.1 An array’s size declarator must be?
A constant integer expression with a value greater than 0.
7.1 Arrays can either be a literal (EX: int days[6];), or?
Named constants.
EX: const int NUM_DAYS = 6;
int days [NUM_DAYS];
7.1 The amount of memory used by an array depends on?
Depends on the array’s data type and the number of elements.
7.1 The size of an array can be calculated by?
By multiplying the size of an individual element by the number of elements in the array.
7.2 What is a subscript?
A number that is assigned to each element in an array.
7.2 What is the use of a subscript?
A subscript is used as an index to pinpoint a specific element within an array.
7.2 Subscript numbering starts at what number?
Subscript numbering in C++ always starts at 0.
7.2 May array elements be used with the cin and cout objects like any other variable?
Yes
7.2 Storing subscript numbers in variable makes it possible to do what?
Makes it possible to use a loop to “cycle through” an entire array, performing the same operation on each element.
7.3 Does C++ perform array bounds checking?
In order to increase runtime efficiency, C++ does not perform array bounds checking.
7.3 In working with arrays, what is a common type of mistake?
Off-by-one error.
7.4 When arrays are defined, they may be?
Arrays may be initialized when they are defined.
7.4 The series of values inside the braces and separated with commas is called?
EX: {1, 2, 3, 4, 5, 6}
An initialization list.
7.4 When an array is being initialized, C++ requires a value for every element. True or false?
False.
It’s possible to only initialize part of an array.
7.4 If an array is being partially initialized, the uninitialized elements will be set to?
Zero
7.4 What is implicit array sizing?
Defining an array without specifying its size, as long as you provide an initialization list.
7.5 What is the range-based for loop?
A specialized version of the for loop. It’s a loop that iterates once for each element in an array. Every time the loop iterates, it copies an element from the array to a variable.
7.5 Range-based for loop was introduced in what version of C++?
C++ 11