chapter 6 test Flashcards
(20 cards)
Suppose that you have declared a numeric array named values that has 13 elements. Which of the following must be true?
b. values[13] is out of bounds
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.
c. can use dayNum, but can also use another numeric value
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 _________.
b. customerCount[regionNum] = customerCount[regionNum] + 1
Two arrays in which each element in one array is associated with the element in the same relative position are _________.
parallel
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. the array has at least five elements
In most modern programming languages, the highest subscript you should use with a 12-element array is _________.
11
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. values[2] = 17
b. input values[0]
c. values[3] = values[0] + 10
d. all of the above ===
Suppose that you have declared a numeric array named numbers, and two of its elements are numbers[1] and numbers[4]. You know that _________.
b. there are exactly two elements between those two elements
Each element in an array must have the same _________ as the others.
a. data type
Each element in a seven-element array can hold _________ value(s).
d. one
A subscript is a(n) _________.
a. number that indicates the position of an array element
The subscripts of any array are always _________.
b. integers
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. output values[3]
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.
three
When you use a subscript value that is negative or higher than the number of elements in an array, _________.
a. the resulting action depends on the programming language used
You can access every element of an array using a _________.
a. for loop
b. while loop
c. either of the above==
Parallel arrays _________.
b. frequently have an indirect relationship
Filling an array with values during a program’s execution is known as _________ the array.
populating
In every array, a subscript is out of bounds when it is _________.
negative
A _________ is a variable that can be set to indicate whether some event has occurred.
flag