Calling Procedures FRQ Practice

Responses receive AI feedback against a rubric after submission. Scores are practice estimates.

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?

Question 2 of 5

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.

Question 3 of 5

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?

Question 4 of 5

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?

Question 5 of 5

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?