Question 1 of 5
PROCEDURE Square (n) { RETURN (n * n) } a ← Square (6) DISPLAY (a) (a) Argument value? (b) Displayed? (c) Role of RETURN in the assignment to a?
Responses receive AI feedback against a rubric after submission. Scores are practice estimates.
PROCEDURE Square (n) { RETURN (n * n) } a ← Square (6) DISPLAY (a) (a) Argument value? (b) Displayed? (c) Role of RETURN in the assignment to a?
PROCEDURE Greet (name) { DISPLAY ("hi") DISPLAY (name) } val ← Greet ("Ann") (a) What is displayed? (b) Does val receive Ann through RETURN? Explain. (c) Rewrite so msg ← Greet ("Ann") can store Ann via RETURN.
PROCEDURE Calc (p, q) { DISPLAY (p) RETURN (p + q) } r ← Calc (2, 5) DISPLAY (r) (a) All displayed values in order? (b) Arguments in the call? (c) Parameters in the header?
PROCEDURE Scale (n, factor) { RETURN (n * factor) } (a) Call storing 20 into out. (b) DISPLAY (Scale (3, 3)) shows? (c) Why Scale (3) alone is invalid for this procedure?
Robot faces north at R. Open cell east of R.
| Row | C1 | C2 |
|---|---|---|
| R1 | R |
PROCEDURE FaceEast
{
ROTATE_RIGHT
}
PROCEDURE Step
{
MOVE_FORWARD
}
FaceEast
Step
(a) Facing after FaceEast? (b) Where after Step? (c) How can procedures without RETURN still change state?