Chapter 7 Flashcards

1
Q
  1. The _________ indicates the number of elements, or values, an array can hold.
A

size declarator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  1. The size declarator must be a(n) _________ with a value greater than _________.
A

integer, 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  1. Each element of an array is accessed and indexed by a number known as a(n) _________.
A

subscript

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. Subscript numbering in C++ always starts at _________.
A

0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

The number inside the brackets of an array definition is the _________, but the number
inside an array’s brackets in an assignment statement, or any other statement that
works with the contents of the array, is the _________

A

size declarator, subscript

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

C++ has no array _________ checking, which means you can inadvertently store data
past the end of an arra

A

bounds

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  1. Starting values for an array may be specified with a(n) _________ list.
A

initialization

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
  1. If an array is partially initialized, the uninitialized elements will be set to _________.
A

0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

If the size declarator of an array definition is omitted, C++ counts the number of items
in the _________ to determine how large the array should be

A

initialization list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

By using the same _________ for multiple arrays, you can build relationships between
the data stored in the arrays

A

subscript

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

You cannot use the _________ operator to copy data from one array to another in a
single statement.

A

=

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Any time the name of an array is used without brackets and a subscript, it is seen as
_________

A

an address

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
  1. To pass an array to a function, pass the _________ of the array.
A

address, or name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
  1. A(n) _________ array is like several arrays of the same type put together.
A

multi-dimensional

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
  1. It’s best to think of a two-dimensional array as having _________ and _________.
A

rows, columns

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
  1. To define a two-dimensional array, _________ size declarators are required.
A

two

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

When initializing a two-dimensional array, it helps to enclose each row’s initialization
list in _________.

A

braces

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

When a two-dimensional array is passed to a function the _________ size must be
specified

A

column

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

The ____________________ is a collection of programmer-defined data types and
algorithms that you may use in your programs

A

Standard Template Library (or STL)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q
  1. The two types of containers defined by the STL are ___________ and ______________.
A

sequence and associative

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q
  1. The vector data type is a(n) ______________ container.
A

sequence

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

To define a vector in your program, you must #include the ____________ header
file

A

vector

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

To store a value in a vector that does not have a starting size, or that is already full,
use the ________________ member function

A

push_back

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

To determine the number of elements in a vector , use the _____________ member
function

A

size

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
39. Use the ________________ member function to remove the last element from a vector .
pop_back
26
40. To completely clear the contents of a vector , use the ___________ member function.
clear
27
An array’s size declarator can be either a literal, a named constant, or a variable
f
28
To calculate the amount of memory used by an array, multiply the number of elements by the number of bytes each element uses
t
29
The individual elements of an array are accessed and indexed by unique numbers.
t
30
The first element in an array is accessed by the subscript 1.
f
31
The subscript of the last element in a single-dimensional array is one less than the total number of elements in the array
t
32
The contents of an array element cannot be displayed with cout .
false
33
Subscript numbers may be stored in variables.
true
34
You can write programs that use invalid subscripts for an array.
true
35
Arrays cannot be initialized when they are defined. A loop or other means must be used.
false
36
The values in an initialization list are stored in the array in the order they appear in the list
true
37
C++ allows you to partially initialize an array.
true
38
If an array is partially initialized, the uninitialized elements will contain “garbage.
false
39
If you leave an element uninitialized, you do not have to leave all the ones that follow it uninitialized
false
40
If you leave out the size declarator of an array definition, you do not have to include an initialization list
false
41
The uninitialized elements of a string array will automatically be set to the value "0"
false
42
You cannot use the assignment operator to copy one array’s contents to another in a single statement
true
43
When an array name is used without brackets and a subscript, it is seen as the value of the first element in the array.
false
44
To pass an array to a function, pass the name of the array.
true
45
When defining a parameter variable to hold a single-dimensional array argument, you do not have to include the size declarator.
true
46
When an array is passed to a function, the function has access to the original array.
true
47
A two-dimensional array is like several identical arrays
true
48
It’s best to think of two-dimensional arrays as having rows and columns.
true
49
The first size declarator (in the declaration of a two-dimensional array) represents the number of columns. The second size definition represents the number of rows.
false
50
Two-dimensional arrays may be passed to functions, but the row size must be specified in the definition of the parameter variabl
false
51
C++ allows you to create arrays with three or more dimensions
true
52
A vector is an associative container
false
53
To use a vector , you must include the vector header file.
true
54
Vector s can report the number of elements they contain.
true
55
You can use the [] operator to insert a value into a vector that has no elements
false
56
If you add a value to a vector that is already full, the vector will automatically increase its size to accommodate the new value
true
57
int size; double values[size];
The size declarator cannot be a variable.
58
81. int collection[-20];
The size declarator cannot be negative.
59
82. int table[10]; for (int x = 0; x < 20; x++) { cout << "Enter the next value: "; cin >> table[x]; }The loop will write data past the end of the array.
The loop will write data past the end of the array.
60
84. int numbers[8] = {1, 2, , 4, , 5};
The initialization list must be enclosed in braces.
61
85. float ratings[];
For the array to be implicitly sized there must be an initialization list.
62
86. char greeting[] = {'H', 'e', 'l', 'l', 'o'}; cout << greeting;
A null terminator must be specified in the initialization list.
63
87. int array1[4], array2[4] = {3, 6, 9, 12}; array1 = array2;
The assignment operator cannot be used to assign the contents of one array to another, in a single statement
64
88. void showValues(int nums) { for (int count = 0; count < 8; count++) cout << nums[count]; }
The parameter should be declared as int nums[]. Also, the function should have a parameter to hold the size of the array
65
89. void showValues(int nums[4][]) { for (rows = 0; rows < 4; rows++) for (cols = 0; cols < 5; cols++) cout << nums[rows][cols]; }
The parameter must specify the number of columns, not the number of rows.
66
90. vector numbers = { 1, 2, 3, 4 };
You do not use an = operator before the initialization list.