Question: What is one task that could be accomplished using a while loop?

Answer Options:
A) When the user inputs a number, the program outputs “True” when the number is a multiple of 10.
B) The user inputs an integer, and the program prints out whether the number is even or odd and whether the number is positive, negative, or zero.
C) After inputting two numbers, the program prints out the larger of the two.
A) user is asked to enter a password repeatedly until either a correct password is entered or five incorrect attempts have been made.

Answer: D) A user is asked to enter a password repeatedly until either a correct password is entered or five incorrect attempts have been made.

Question: A program adds a service fee to the total cost of concert tickets when the tickets are printed and mailed to customers. Another service fee is also added if the tickets are delivered overnight. Which control structure should be used?

Answer Options:
A) If statement
B) While loop
C) Do-while loop
D) Multiple if statements

Answer: D) Multiple if statements

Question: Which output results from the following pseudocode? x = 5 do x = x + 4 while x < 18 Put x to output

Answer Options:
A) 09
B) 018
C) 021
D) 025

Answer: C) 21

Question: What is the output of the given flowchart if the input is 54?

Answer Options:
A) Pending for later.

Answer: A) Pending for later.

Question: Which snippet represents the loop variable update statement in the given code?

Answer Options:
A) h = h + 2
B) Put h to output
C) h < 30
D) integer h = 2

Answer: A) h = h + 2

Question: Which line is a loop variable update statement in the sample code?

Answer Options:
A) integer h = 0
B) if userInput == pwd
C) h = h + 1
D) (userInput l= pwd) and (h <= 10)

Answer: C) h = h + 1

Question: The steps in an algorithm to calculate the positive difference in two given values, x and y, are given in no particular order.

Answer Options:
A) Put Diff to output.
B) Declare variable Diff.
C) Set Diff = x – y.
D) If y > 2, set Diff = y – x.

Answer: B) Declare variable Diff.

Question: The steps in an algorithm to build a picnic table are given.

Answer Options:
A) 1 and 2
B) 2 and 3
C) 1 and 3
D) 2 and 4

Answer: C) 1 and 3

Question: Order the tasks needed to safely replace a lamp’s light bulb from first (1) to last (4).

Answer Options:
A) Screw in working bulb.
B) Turn lamp off.
C) Turn lamp on.
D) Unscrew broken bulb.

Answer: Turn lamp off. Unscrew broken bulb. Screw in working bulb.

Question: What is the outcome for the given algorithm? Round to the nearest tenth, if necessary.

Answer Options:
A) 5.0
B) 6.0
C) 6.1
D) 8.4

Answer: B) 6.0

Question: Which output results from the given algorithm?

Answer Options:
A) 1
B) 5
C) 10
D) 60

Answer: C) 10

Question: What does the following algorithm determine?

Answer Options:
A) Whether x is evenly divisible by 2 or 3
B) Whether x is odd
C) Whether x is even
D) Whether x is negative, 0, or positive

Answer: D) Whether x is negative, 0, or positive

Question: Which problem is solved by Dijkstra’s shortest path algorithm?

Answer Options:
A) Given the coordinates of five positions, what is the most fuel-efficient flight path?
B) Given two newspaper articles, what is the greatest sequence of words shared by both articles?
C) Given an increasing array of numbers, is the number 19 in the array?
D) Given an alphabetized list of race entrants and a person’s name, is the person entered in the race?

Answer: A) Given the coordinates of five positions, what is the most fuel-efficient flight path?

Question: What is an example of an algorithm?

Answer Options:
A) webpage uses an HTML file type.
B) The list contains apples, bananas, and oranges.
C) The sign of two integers determines the sign of the product.
D) Unplug the device, wait 30 seconds, and restart the device.

Answer: D) Unplug the device, wait 30 seconds, and restart the device.

Question: A particular sorting algorithm takes integer list 10, 6, 8 and incorrectly sorts the list to 6, 10, 8. What is true about the algorithm’s correctness for sorting an arbitrary list of three integers?

Answer Options:
A) The algorithm’s correctness is unknown.
B) The algorithm is incorrect.
C) The algorithm only works for 10, 6, 8.
D) The algorithm is correct.

Answer: B) The algorithm is incorrect.

Question: An algorithm should output “OK” if a number is between 98.3 and 98.9, else the output is “Not OK.” Which test is a valid test of the algorithm?

Answer Options:
A) Input 99.9. Ensure output is “98.9.”
B) Input 99.9. Ensure output is “OK.”
C) Input 98.6. Ensure output is “OK.”
D) Input 98.6. Ensure output is “Not OK.”

Answer: C) Input 98.6. Ensure output is “OK.”

Question: Consider the given flowchart.

Answer Options:
A) Within 2
B) Equal
C) Not close
D) Within 5

Answer: B) Equal