1/19
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
A subscript is a(n) ___. (6.1)
a. element in an array
b. alternate name for an array
c. number that represents the highest value stored within an array
d. number that indicates the position of an array element
number that indicates the position of an array element
Each element in an array must have the same ___ as the others. (6.1)
a. data type
b. subscript
c. value
d. memory location
data type
Suppose that you have declared a numeric array named ‘values’ that has 13 elements. Which of the following must be true? (6.1)
a. 'value [0]' is smaller than 'value [1]'
b. 'value [2]' is stored adjacent to 'value [4]'
c. ‘values [13]’ is out of bounds
d. 'values [12]' holds the largest value in the array
‘values [13]’ is out of bounds
The subscripts of any array are always ___. (6.1)
a. integers
b. fractions
c. characters
d. strings of characters
integers
Suppose that you have declared a numeric array named ‘numbers’, and two of its elements are numbers [1] and number [4]. You know that ___. (6.1)
a. the two elements hold the same value
b. the array holds exactly four elements
c. there are exactly two elements between those two elements
d. the two elements are the same memory location
there are exactly two elements between those two elements
Suppose that you have declared a numeric array named ‘numbers’ and two of its elements are ‘numbers [1]’ and ‘numbers [4]’. You know that ___. (6.1)
a. ‘numbers [4]’ is larger than ‘numbers [1]’
b. the array has at least five elements
c. the array has been initialized
d. the two elements are three bytes apart in memory
the array has at least five elements
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 $1,000 each is displayed. The most likely statement during the main processing loop would be _____. (6.2)
a. ‘customerCount[balance] = customerCount[balance] + 1’
b. ‘customerCount[regionNum] = customerCount[regionNum] + 1’
c. ‘customerCount[regionNum] = regionNum - 1’
d. ‘customerCount[balance] = balance + customerCount[regionNum]’
‘customerCount[regionNum] = customerCount[regionNum] + 1’
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 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. (6.2)
a. must use ‘dayNum’
b. can use ‘dayNum’, but can also use another numeric value
c. must not use ‘dayNum’
d. must use a numeric constant instead of a variable
b. can use ‘dayNum’, but can also use another numeric value
Suppose that you have declared an array as follows: ‘num values[4] = 0, 0, 0, 0’. Which of the following is not allowed operation? (6.1, 6.3)
a. ‘values[2] = 17’
b. ‘input values[0]’
c. ‘values[3] = values[0] + 10’
d. ‘output values [4]’
‘output values [4]’
Suppose that you have declared an array as follows: ‘num values[4] = 0, 0, 0, 0’. Which of the following is an allowed operation? (6.1)
a. ‘values[4] = 80’
b. ‘values[2] = values[4] - values[0]’
c. ‘output values[3]’
d. ‘values[1] = 30’
‘output values[3]’
Fillling an array with values during a program’s execution is known as ___ the array. (6.1)
a. executing
b. colonizing
c. populating
d. declaring
populating
A ___ is a variable that can be set to indicate whether some event has occurred. (6.5)
flag
Two arrays in which each element in one array is associated with the element in the same relative position are ____. (6.5)
a. cohesive
b. parallel
c. hidden
d. perpendicular
parallel
In most modern programming languages, the highest subscript you should use with a 12-element array is _____. (6.1, 6.7)
a. 10
b. 11
c. 12
d. 13
11
The values stored in parallel arrays ___. (6.5)
a. frequently have an indirect relationship
b. never have an indirect relationship
c. must be the same data type
d. must not be the same data type
frequently have an indirect relationship
Each element in a seven-element array can hold ___ value(s). (6.1)
a. one
b. seven
c. at least seven
d. an unlimited number of
one
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. (6.6)
a. ten
b. five
c. four
d. three
three
When you use a subscript value that is negative or higher than the number of elements in an array, ______________.
a. execution of the program stops and an error message is issued
b. a value in a memory location that is outside the area occupied by the array will be accessed
c. a value in a memory location that is outside the area occupied by the array will be accessed, but only if the value is the correct data type
d. the resulting action depends on the programming language used
the resulting action depends on the programming language used
In every array, a subscript is out of bounds when it is _________. (6.7)
a. negative
b. 0
c. 1
d. 999
negative
You can access every element of an array using a _____. (6.8)
d. neither a ‘while’ loop or a ‘for’ loop
either a ‘while’ loop or a ‘for’ loop