Calling Procedures MCQ Practice

Question 1 of 10

What is displayed?

PROCEDURE Triple (n)
{
  RETURN (n * 3)
}
DISPLAY (Triple (4))
  1. A. 4
  2. B. 7
  3. C. 12
  4. D. 3

Question 2 of 10

Which is accurate?

PROCEDURE PrintPlusOne (n)
{
  DISPLAY (n + 1)
}
value ← PrintPlusOne (6)
DISPLAY (value)
  1. A. Nothing is displayed.
  2. B. value becomes 6.
  3. C. value becomes 7 because DISPLAY returns 7.
  4. D. 7 is displayed inside the procedure; value is not assigned via RETURN.

Question 3 of 10

What is displayed?

PROCEDURE Clamp (n)
{
  IF (n < 0)
  {
    RETURN (0)
  }
  ELSE
  {
    RETURN (n)
  }
}
DISPLAY (Clamp (-2))
DISPLAY (Clamp (5))
  1. A. 0 then 5
  2. B. 0 then 0
  3. C. 5 then 0
  4. D. -2 then 5

Question 4 of 10

PROCEDURE Mix (a, b) { RETURN (a) }. DISPLAY (Mix (9, 2))?

  1. A. Mix
  2. B. 9
  3. C. 2
  4. D. 11

Question 5 of 10

What is displayed?

PROCEDURE Sum3 (x, y, z)
{
  RETURN (x + y + z)
}
s ← Sum3 (1, 2, 3)
t ← Sum3 (s, 0, 0)
DISPLAY (t)
  1. A. 0
  2. B. 3
  3. C. 6
  4. D. 123

Question 6 of 10

Parameters are best described as:

  1. A. Only values produced by DISPLAY
  2. B. Robot wall markers
  3. C. Values written in a call like Circle (5)
  4. D. Named inputs in a PROCEDURE header that receive argument values

Question 7 of 10

What is displayed?

PROCEDURE Label (n)
{
  DISPLAY ("n=")
  DISPLAY (n)
  RETURN (n)
}
x ← Label (3)
DISPLAY (x)
  1. A. n= then 3 then 3
  2. B. n= only
  3. C. 0
  4. D. Only 3 once

Question 8 of 10

Correct assignment for PROCEDURE Avg (a, b) { RETURN ((a + b) / 2) }?

  1. A. Avg (4, 6)
  2. B. mean ← Avg (4, 6)
  3. C. RETURN ← Avg (4, 6)
  4. D. Avg ← 4 + 6

Question 9 of 10

No-parameter procedure. Which call form displays returned 0?

PROCEDURE Zero
{
  RETURN (0)
}
DISPLAY (Zero ())
  1. A. Only robot procedures may return 0
  2. B. Only DISPLAY (Zero) without parentheses is required
  3. C. DISPLAY (Zero ()) uses an empty argument list and displays the returned 0
  4. D. Neither form can display 0

Question 10 of 10

Procedure body uses DISPLAY but no RETURN. Caller: result ← Proc (2). True claim?

  1. A. result always equals the number of parameters.
  2. B. result is guaranteed to equal 2.
  3. C. Proc cannot run because all procedures must RETURN.
  4. D. Proc can display something, but it provides no returned value for the assignment.