AP CSP Day 43: Procedure Parameters & Return
Share
Big Idea 3
Day 43 Practice
Focus: Procedure Parameters & Return
Practice Question
A procedure is defined as:
PROCEDURE mystery(x, y)
{
IF (x > y)
{
RETURN x
}
ELSE
{
RETURN y
}
}
What does mystery(5, 8) return?Why This Answer?
The procedure returns the larger of two values. Since 8 > 5, it returns 8 (the maximum).
Why Not the Others?
A) 5 is smaller, so not returned.
C) The procedure returns max, not sum.
D) Parameters are valid integers.
Common Mistake
Watch Out!
Misreading the IF condition. x > y is false (5 > 8 is false), so ELSE executes, returning y.
AP Exam Tip
Trace through conditionals carefully. Check which branch executes based on the condition.