Confidential Teaching Materials:
Quiz 3 Grading Criteria
Note: To receive any credit whatsoever, the date, your name, your student number, and your answers must
be legible and readily readable in the judgment of the grader.
Add brief explanatory comments as necessary to make sure your answers are clear and unambiguous
to the grader.
[p1] 25.0
What is the output of the following algorithm? Include a separate line for each print statement.
//NOTE: the choice of variable/parameter names in the following
// code is intentionally very poor. Do not turn in anything
// like this for homework, or you will face penalties!
algorithm Trace_it_if_you_Can
num1,
num2,
num3 isoftype Num
num1 <- 5
num2 <- 3
num3 <- 7
print(num2, num3, num1)
SwitchAround(num3, num2, num1)
print(num3, num1, num2)
WatchOut(num2, num1, num3)
print(num1, num2, num3)
endalgorithm //Trace_it_if_you_Can
procedure SwitchAround(num1, num2 isoftype in/out Num, num3 is of type in Num)
num1 <- num1 + num2
num2 <- num3
num3 <- num1
print(num1, num2, num3)
endprocedure //SwitchAround
procedure WatchOut(num1 isoftype out Num, num2 isoftype in Num,
num3 isoftype in/out Num)
num1 <- num2 * num3
num2 <- num2 * num3
num3 <- num1 + num2
print(num1, num3, num2)
endprocedure //WatchOut
LINES = 8
[c1] 25 points