Skip to main content
AP CSP course

C39 · Topic 3.12 · 40 minutes · AAP-3.A

Arguments, parameters and calls

By the end you can:

  • Match arguments by position.
  • Create a fresh local trace for each call.
  • Choose inputs that expose argument-order mistakes.

Before this lesson: topics 3.1, 3.6.

Parameter
A name in a procedure definition that receives an argument value.
Argument
A value supplied in a particular procedure call.

Understand

A procedure groups instructions under a name and may accept parameters. Arguments are supplied in a call and match parameters by position under the AP convention. Different names in the caller do not alter that ordering, so read the definition and call together rather than guessing from the argument variable names.

Each call uses its supplied values. Trace the parameter bindings before evaluating the body, especially when operations are not symmetric. Equal arguments or a commutative expression can conceal a swap; a good distinguishing test assigns different values to roles that produce different results when exchanged.

Worked example

quote(base,perItem,count)returns base+perItem*count.

PROCEDURE quote(base,perItem,count)
{ RETURN(base + perItem * count) }
  1. quote(5,2,3)binds base 5,perItem 2,count 3.
  2. The expression gives 5+6=11.
  3. quote(2,5,3)instead gives 2+15=17, exposing a swap of the first two roles.

Explore each concept

Choose a concept, change its inputs and follow the explanation. Each example models the stated rule or scenario; completing it is practice rather than evidence of mastery.

  • Argument binding and local calls
  • RETURN ends the call
  • DISPLAY is not a returned value
Open this example on its own

Change it · step through · explain

Change an input, predict what will happen, then advance one step. Read why the state changes, reset and experiment. This fixed teaching model does not save progress or award XP.

Ready · Make a prediction

Ready to explore: Call, return, display and resume
  1. Argument (0–10)3Waiting
  2. Procedure bodyreturnWaiting

Ready to explore: Call, return, display and resume

Why: Change an input, predict the first effect, then advance one step.

Try this: Change one input or choose another listed case. Predict the effect, reset and compare the states and governing rule.

Step through and experiment

Change it · step through · explain

Change an input, predict what will happen, then advance one step. Read why the state changes, reset and experiment. This fixed teaching model does not save progress or award XP.

Ready · Make a prediction

Ready to experiment
  1. Input 15Waiting
  2. Input 22Waiting
  3. Input 33Waiting

Ready to experiment

Why: Predict the first change, then advance one step.

Try this: Change one input, predict the difference, then reset and compare.

Check a misconception

Claim: Argument variables match parameters by their names regardless of position.

Position determines the binding under this call convention.

Guided practice

Trace quote(4,3,2), naming every binding.

Work with a partner. Make a prediction, compare your reasoning, then identify the rule that supports your answer.

Independent transfer

Give a weak and a stronger test for swapping base and perItem.

Exit check

Why should you write bindings before the calculation?

Write your reasoning before comparing with a classmate. If your teacher assigned this task, submit it through My classes to save your work and receive feedback.

Check yourself

  1. Question 1 of 2In quote(8,2,4), which value goes to perItem?

    Select one answer.

  2. Question 2 of 2What does quote(5,2,0)return?

    Select one answer.

Your practice so far

Check an answer to see its rationale.

Teacher guidance and scoring