OOPortal OOPortal


Structured Programming  «Prev  Next»

Control Flow Constructs - Quiz

Each question is worth one point. Select the best answer or answers for each question.
1. The following pseudocode presents an example of which control flow construct?
If the service was good
  Leave a 15% tip
Otherwise
  Leave a 10% tip

Please select the best answer.
  A. Decision
  B. Compilation
  C. Repetition

2. Which of the control flow constructs is used to execute the same statements over and over?
Please select the best answer.
  A. Decision
  B. Compilation
  C. Repetition

3. Consider the following pseudocode for a program involving cookies, marbles, and a hat. Assuming that when the program starts the cookie jar contains 3 cookies and the hat is empty, what will the hat contain when the program completes?

While the cookie jar is not empty
  Put a red marble in the hat
  If the hat contains an even number of marbles
    Put a blue marble in the hat
  Eat a cookie from the jar

Please select the best answer.
  A. 2 red marbles and 1 blue marble
  B. 3 red marbles and 1 blue marble
  C. 3 red marbles and 2 blue marbles

Score =
Correct answers: