Quiz Score: 66/67
Missed Question:
The following procedure is intended to return the value of x times y, where x and y are integers. Multiplication is implemented using repeated additions.
For which of the following procedure calls does the procedure NOT return the intended value?
Select two answers.
A: Multiply(2, 5)
B: Multiply(2, -5)
C: Multiply(-2, 5)
D: Multiply(-2, -5)
Selected Answer:
B: Multiply(2, -5)
Correct Answers:
B: Multiply(2, -5)
D: Multiply(-2, -5)
The above program attempts to create a function to multiply two number with each other using repeated addition. It does this by repeating a loop until it reaches the second value, and adds the first number to a new variable each time. This works in some cases, however the major flaw is that the program assumes that the second number is above zero, and therefore increases the number. If the number is below zero, then the program will return zero, as the count variable is already greater than y. Therefore, answers B and D are correct since those two have a negative number in the second parameter, which will result in the incorrect value of 0. C is not correct and will produce the correct result, as a negative value in the first number will result in this negative number added to itself, or subtracted, however many times the second number, therefore not affecting the result and returning the proper answer.
Overall, this practice test went pretty well for a variety of reasons. Past experience helped on some questions, and the team teach lessons before break definitely helped and many questions showe up on those topics. Those lessons made this easier than the first time, and meant no research was needed on these questions. Occaisionally I encoutered a question on a topic I hadn’t heard of, and rather than blindly guessing, I preferred to do research on the topic and learn about that topic for the future, rather than learn it during test corrections. Either way I am now familiar with those topics, both of which are better than simply googling the answer and copy pasting without reading. Overall, this test went well but more review and practice is likely needed for the AP test MC.