Exam Questions Arrays: Lists and Tables Chapter 7 6e - Practice Test Bank | Prelude Programming 6e Venit by Stewart Venit. DOCX document preview.
Test Bank for Prelude to Programming Chapter 7
MULTIPLE CHOICE
1. A list of related data of the same data type which is referred to by a single variable name with an index number to identify each item is a(n):
a. | list |
b. | database |
c. | array |
d. | element |
2. The fourth element of an array named Colors is identified as:
a. | Colors[0] |
b. | Colors[3] |
c. | Colors[4] |
d. | Colors[5] |
3. Which is the correct way to load an array named WorkHours with the number of hours that five employees worked last week?
a. | Declare WorkHours[5] As Float Declare J As Integer For (J = 0; J <= 4; J++) Write “Input number hours worked for employee” + J + 1 Input WorkHours[J] End For |
b. | Declare WorkHours[4] As Float Declare J As Integer For (J = 0; J <= 4; J++) Write “Input number hours worked for employee” + J + 1 Input WorkHours[J + 1] End For |
c. | Declare WorkHours[5] As Float Declare J As Integer For (J = 0; J<=5; J++) Write “Input number hours worked for employee” + J Input WorkHours[J + 1] End For |
d. | None of these are correct |
4. Two arrays of the same size in which elements with the same subscript are related are:
a. | one-dimensional arrays |
b. | two-dimensional arrays |
c. | parallel arrays |
d. | sorted arrays |
5. What is displayed when code corresponding to the following pseudocode is executed?
Declare Numbers[12] As Integer
Set K = 0
While K <= 2
Set Numbers[3 * K] = K + 1
Write Numbers[3 * K]
Set K = K + 1
End While
a. | 0 3 6 | b. | 1 2 | c. | 1 2 3 | d. | 0 3 |
6. What is displayed when code corresponding to the following pseudocode is executed?
Declare B[4] As Float
Set B[3] = 9.8
Set K = 0
While K <= 3
Set B[K] = K/2
Write B[K]
Set K = K + 1
End For
a. | 0 .5 1 1.5 | b. | .5 1 1.5 | c. | 0 .5 1 9.8 | d. | .5 1 1.5 9.8 |
7. What will be displayed after code corresponding to the following pseudocode is run?
Declare MyName[25] As Character
Set MyName = “Harry5”
Write Length_Of(MyName)
a. | 5 | b. | Harry5 | c. | 25 | d. | 6 |
8. Given the following pseudocode, what is stored in Puppy[3]?
Declare Puppy[12] As Character
Set Puppy = “ROVER”
a. | R | b. | O | c. | V | d. | E | e. | R |
9. If we know that 100 elements have been allocated to a two-dimensional array named MyArray, which of the following is not a possible way to declare MyArray?
a. | Declare MyArray[10, 10] |
b. | Declare MyArray[25, 4] |
c. | Declare MyArray[20, 5] |
d. | all of the above are possible |
10. If a string variable, Puppy, has been declared to be an array of 7 characters, which of the following strings cannot be stored in Puppy?
a. | “Rover” |
b. | “Spot” |
c. | “Labrador” |
d. | “X” |
11. If a two-dimensional array named Months stores the months of the year in the first column and the days of each month in the second column, which of the following represents the element that stores March 12, where March is the third month of the year?
a. | Months[2, 11] | b. | Months[3, 11] |
c. | Months[3, 12] | d. | Months[2, 12] |
12. What is the outcome of code corresponding to the following pseudocode?
Declare G[100]
Set N = 4
For (J = 0; J <= N; J++)
Set G[J] = J * 4
End For
Write G[N/2]
Write G[1] + “ “ + G[N–1]
a. | 0 4 8 | b. | 4 8 16 | c. | 8 4 12 | d. | 0 1 3 |
13. Given an array named Stuff, how many elements will be filled with the following loop?
For (K = 0; K <= 9; K+2)
Set Stuff[K] = K
End For
a. | 4 | b. | 5 | c. | 6 | d. | 9 |
14. What is displayed if the following pseudocode is coded and run?
Declare Name As String
Declare NameLength As Integer
Set Name = “Peter Pan”
Set NameLength = Length_Of(Name)
Write NameLength
a. | Peter Pan | b. | 8 | c. | 9 | d. | Nothing, the types don’t match |
15. What is the outcome of code corresponding to the following pseudocode?
Declare Answer[4] As Integer
Declare A, B, As Integer
For (A = 0; A <= 3; A++)
For (B = 1; B <= 3; B++)
If A == B Then
Set Answer[A] = 100
Else
Answer[A] = A + B
End If
End For(B)
End For(A)
For (A = 1; A <= 3; A++)
Write Answer[A]
End For(A)
a. | 1 100 3 4 | b. | 0 1 2 3 | c. | 1 4 5 100 | d. | 100 100 100 100 |
TRUE/FALSE
1. True/False: Arrays are used in input, processing, and output operations.
2. True/False: Arrays save space because all elements of an array are stored in a single memory location while a list of variables needs a separate location for each variable.
3. True/False: The following statement: Declare Array1[23] allocates storage space for 22 elements.
4. True/False: The following statement: Declare ArrayX[5,5] allocates storage space for 25 elements.
5. True/False: The third element of an array named Dogs is identified by Dogs[3].
6. True/False: Parallel arrays are arrays of the same size in which elements of the same subscript are related.
7. True/False: In some programming languages, strings are implemented as arrays whose elements are characters.
8. True/False: The Length_Of function can only be used on arrays that contain numeric data.
9. True/False: To input a string from a user, we must know beforehand exactly how many characters are in that string.
10. True/False: An array does not have to be declared of any data type.
11. True/False: Databases consist of many linked tables.
12. True/False: To obtain information from a database, a programmer or database administrator would use a query.
13. True/False: A rectangular grid of numbers (rows and columns) is known as a matrix.
14. True/False: The following statement results in answer = true:
Set answer = Length_Of(“hello”)
SHORT ANSWER
1. A string variable can be declared as an array with elements that are of __________ type.
2. Each element in an array is identified by its __________.
3. A(n) _______ __________ array named FullName is declared as FullName[x, y].
4. The Declare statement allocates __________ storage locations to the array named Photos[23].
5. The elements of an array are stored in __________ storage locations in the computer’s memory.
6. In parallel arrays, corresponding elements in each array must have the same __________.
7. The index number of the first element of an array, using the pseudocode of this textbook, is __________.
8. The __________ operator is used to join two strings.
9. The __________ function will return the number of characters in a given string.
10. The statement Declare MyArray[8,6] allocates __________ consecutive storage locations in the computer’s internal memory.
11. Databases consist of many linked tables that may be thought of as __________ lists.
12. When using information from a database, programmers often store the information from the database __________ in __________.