Chapter 7 Flashcards Preview

Computer Science > Chapter 7 > Flashcards

Flashcards in Chapter 7 Deck (70)
Loading flashcards...
1

What is the difference between a size declarator and a subscript?

The size declarator is used in a definition of an array to indicate the number of elements the array will have.
A subscript is used to access a specific element in an array

2

Look at the following array definition:

int values [10];

How many elements does the array have?

10

3

Look at the following array definition:

int values [10];

What is the subscript of the first element in the array?
What is the subscript of the last element in the array?

0

9

4

Look at the following array definition:

int values [10];

Assuming that an int uses four bytes of memory, how much memory does the array use?

40 bytes

5

Why should a function that accepts an array as an argument, and processes that array, also accept an argument specifying the array size?

Because, with the array alone, the function has no way of determining the number of elements it has.

6

How do you define an array without providing a size declarator?

By providing an initialization list. The array is sized to hold the number of values in the list

7

Assuming that array1 and array 2 are both arrays, why is it not possible to assign the contents of array2 to array1 with the following statement?

array1 = array2;

An array name without brackets and a subscript represents the array's beginning memory address. The statement shown attempts to assign the address of array2 to array1, which is not permitted.

8

Is an array passed to a function by value or by reference?

By reference

9

When you pass an array name as an argument to a function, what is actually being passed?

The array's beginning memory address

10

How do you establish a parallel relationship between two or more arrays?

By using the same subscript value for each array

11

Look at the following array definition:

double sales [8] [10];

How many rows does the array have?
How many columns does the array have?
How many elements does the array have?

8 rows
10 columns
80 elements

12

When writing a function that accepts a two-dimensional array as an argument, which size declarator must you provide in the parameter for the array?

The second size declarator, which is for the number of columns

13

What advantages does a vector offer over an array?

1. you dont have to declare the number of elements that a vector will have
2. If you add a value to a vector that is already full, the vector will automatically increase its size to accommodate the new value
3. a vector can report the number of elements it contains

14

The ______ indicates the number of elements, or values, an array can hold.

size declarator

15

The size declarator must be a(n) ______ with a value greater than ______.

integer
0

16

Each element in an array is accessed and indexed by a number known as a(n) ______.

subscript

17

Subscript numbering in C++ always starts with ______.

0

18

The number inside the brackets of an array definition is the ______, but the number inside an array's brackets is an assignment statement, or any other statement that works with the contents of the array, is the ______.

size declarator
subscript

19

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

bounds

20

Starting values for an array may be specified with a(n) ______ list.

inititalization

21

If an array is partially initialized, the uninitialized elements will be set to ______.

0

22

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.

initialization list

23

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

subscript

24

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

assignment (=)

25

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

an address

26

To pass an array to a function, pass the ______ of the array

address, or name

27

A(n) ______ array is like several arrays of the same type put together

multi-demensional

28

It is best to think of a two-dimensional array as having ______ and ______.

rows, columns

29

To define a two-dimensional array, ______ size declarators are required

two

30

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

braces