Multiple Choice Answers

CMIS102_Quiz2_Answer BS102

1. What will be displayed if code corresponding to the following pseudocode is executed?

Set Number = 4
Repeat
Write 2 * Number
Set Number = Number + 2
Until Number == 8
a. 8        b. 4        c. 8        d. 12
12          8           12          16
16          12

2. What will be displayed after code corresponding to the following pseudocode is run?
Set Count = 2
While Count < 10
Set Count = Count + 2
Write Count
End While
a. 2        b. 2        c. 4        d. 4
4           4           6           6
6           6           8           8
8           8           10
10

3. A counter must be:
a. a positive number
b. a float
c. an integer
d. a variable named Count

4. Given that the value of Count is 23, what will be the value of Count after the following statement is executed:
Set Count = Count + 2
a. 23
b. 25
c. 48
d. 24

5. What will be displayed after code corresponding to the following pseudocode is run?
Set Count = 10
While Count > 0
Write Count
Set Count = Count – 2
End While
a. 10        b. 10        c. 8        d. 8
8            8           6           6
6            6           4           4
4            4           2           2
2            2                       0
0

6.  What is the output of the code corresponding to the following pseudocode?
Declare X As Integer
Declare Y As Integer
For (X = 1; X <=2; X++)
For (Y = 3; Y <= 4; Y++)
Write X * Y
End For(Y)
End For(X)
a.  3       b.  4      c.  1      d.  3 4
4           5          3          6 8
6           5          2
8           6          4

7.  Which of the following loops cannot be nested inside a For loop?
a. While
b. For
c. Repeat … Until
d. Do … While
e. all of the above can be nested inside a For loop

8. True/False: It is possible to have both a Select Case statement and an If-Then structure within a single loop structure.

9. If Number = 7, what will be displayed after code corresponding to the following pseudocode is run?
For (Count = 5; Count <= Number; Count = Count + 1)
Write Count + ” ” + Count * 2
End For
a. 5 10        b. 5  10        c. 5  10        d. 5  7
6 12           6  12           7  14           10 14
7 14

10. Given the following program segment, what is the test condition?
Write “Enter your response (Y/N): ”
Input Answer
If Answer == “No” Then
Write “Try Again: ”
Input Answer
End If
Write “Are you having fun yet? (Y/N)”
Input Response
a. Answer
b. Answer == “No”
c. Response
d. Answer = “Y”

11. Given the following program segment, if the user inputs  “Hooray” on Line 2, what Line will be executed after Line 3?
1. Write “Enter your response (Y/N): ”
2. Input Answer
3. If Answer == “No” Then
4.     Write “Try Again: ”
5.     Input Answer
6. End If
7. Write “Are you having fun yet?”
8. Input Response
a. Line 4
b. Line 5
c. Line 7
d. Line 8

12. What is the output of code corresponding to the following program segment if Age = 18?
If Age >= 18 Then
Write “You are eligible to vote.”
Else
Set Years = 18 – Age
Write “You can vote in ” + Years + ” years.”
End If

a. You are eligible to vote.
b. You can vote in 18 years.
c. You are eligible to vote.
You can vote in 18 years.
d. You can vote in 0 years.

13. Which of the following is a type of selection structure?
a. single-alternative
b. dual-alternative
c. multiple-alternative
d. Case or switch
e. all of the above are types of selection structures

14. Given that Marcy worked 42 hours (Hours = 42) last week and earns $10.00 an hour (Rate = 10), how much did Marcy earn last week, before taxes (TotalPay)?
If (Rate >= 10) AND (Hours <= 40) Then
TotalPay = Hours * Rate
Else
TotalPay = (40 * Rate) + (Hours – 40) * Rate * 1.5
End If
a. $ 500
b. $ 420
c. $ 430
d. $ 650

15. If Apples = 2, what will be displayed after code corresponding to the following pseudocode is run?
While Apples < 0
Write “You can’t eat ” + Apples + ” at one time!”
End While
Write “Goodbye, apple lover.”
a. You can’t eat 2 apples at one time!
Good bye, apple lover.
b. will display nothing
c. You can’t eat apples at one time!
d. Goodbye, apple lover.

16.  The fourth element of an array named Colors is identified as:
a. Colors[0]
b. Colors[3]
c. Colors[4]
d. Colors[5]

17.  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

18.  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

19.  Which of the following will test to make sure the number entered by the user into the variable named InRange is between 5 and 50 (inclusive of both 5 and 50)?
a. If (InRange > 5) AND (InRange < 50) Then …
b. If (InRange >= 5) AND (InRange <= 50) Then …
c. If (InRange > 5) OR (InRange < 50) Then …
d. If (InRange >= 5) OR (InRange <= 50) Then …

20. 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         b. 1           c. 1            d. 0
3            2              2               3
6            3

21.  If X = 6, Y = 9, and Z = 0, what values are in X, Y, and Z after code corresponding to the following pseudocode is executed?
Set Z = X
Set X = Y
Set Y = Z
a.  X = 9
Y = 6
Z = 0
b.  X = 0
Y = 6
Z = 9
c.  X = 9
Y = 6
Z = 9
d.  X = 9
Y = 6
Z = 6

22.  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

23. 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

24. 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]

25. What is the outcome of code corresponding to the following pseudocode?
Declare G[100] As Integer
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