chapter 6 test Flashcards

(20 cards)

1
Q

Suppose that you have declared a numeric array named values that has 13 elements. Which of the following must be true?

A

b. values[13] is out of bounds

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

A program contains a seven-element array that holds the names of the days of the week. At the start of the program, you display the day names using a subscript named dayNum. You display the same array values again at the end of the program, where you _________ as a subscript to the array.

A

c. can use dayNum, but can also use another numeric value

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

Suppose that you want to write a program that inputs customer data including name, zipCode, balance, and regionNum. At the end of the program, a summary of the number of customers in each of 12 sales regions who owe more than $1000 each is displayed. The most likely statement during the main processing loop would be _________.

A

b. customerCount[regionNum] = customerCount[regionNum] + 1

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

Two arrays in which each element in one array is associated with the element in the same relative position are _________.

A

parallel

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

Suppose that you have declared a numeric array named numbers, and two of its elements are numbers[1] and numbers[4]. You know that _________.

A

a. the array has at least five elements

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

In most modern programming languages, the highest subscript you should use with a 12-element array is _________.

A

11

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

Suppose that you have declared an array as follows: num values[4] = 0, 0, 0, 0. Which of the following is an allowed operation?

A

a. values[2] = 17
b. input values[0]
c. values[3] = values[0] + 10
d. all of the above ===

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

Suppose that you have declared a numeric array named numbers, and two of its elements are numbers[1] and numbers[4]. You know that _________.

A

b. there are exactly two elements between those two elements

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

Each element in an array must have the same _________ as the others.

A

a. data type

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

Each element in a seven-element array can hold _________ value(s).

A

d. one

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

A subscript is a(n) _________.

A

a. number that indicates the position of an array element

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

The subscripts of any array are always _________.

A

b. integers

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

Suppose that you have declared an array as follows: num values[4] = 0, 0, 0, 0. Which of the following is an allowed operation?

A

a. output values[3]

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

Suppose that an instructor assigns different letter grades based on points earned on a 10-point quiz, and that all scores have been verified to be between 0 and 10 inclusive. Also suppose that four possible letter grades can be assigned and that 9 or 10 points is an A, 7 or 8 points is a B, 6 points is a C, and 5 or fewer points is an F. To assign letter grades, the most efficient numeric array containing point values would contain _________ elements.

A

three

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

When you use a subscript value that is negative or higher than the number of elements in an array, _________.

A

a. the resulting action depends on the programming language used

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

You can access every element of an array using a _________.

A

a. for loop
b. while loop
c. either of the above==

17
Q

Parallel arrays _________.

A

b. frequently have an indirect relationship

18
Q

Filling an array with values during a program’s execution is known as _________ the array.

19
Q

In every array, a subscript is out of bounds when it is _________.

20
Q

A _________ is a variable that can be set to indicate whether some event has occurred.