Fiveable

⌨️AP Computer Science Principles Unit 3 Review

QR code for AP Computer Science Principles practice questions

3.12 Calling Procedures

3.12 Calling Procedures

Written by the Fiveable Content Team • Last updated June 2026
Verified for the 2027 exam
Verified for the 2027 examWritten by the Fiveable Content Team • Last updated June 2026
⌨️AP Computer Science Principles
Unit & Topic Study Guides

AP Computer Science Principles Exam

Pep mascot

A procedure is a named group of instructions you can run again and again by calling it, instead of rewriting the same code. When you call a procedure, you pass in arguments that fill its parameters, the program runs the procedure's statements, and then control returns to the line right after the call. For AP Computer Science Principles, track how arguments map to parameters, what the procedure changes, and where the program continues after the call.

Why This Matters for the AP Computer Science Principles Exam

Calling procedures shows up a lot in the multiple-choice section, where you trace pseudocode and figure out what a procedure call produces or changes. You need to know how arguments map to parameters, how flow of control jumps into a procedure and comes back, and how RETURN sends a value back to where the procedure was called.

This topic also supports the Create performance task. Using procedures with parameters is one of the clearest ways to manage complexity in your own program, and writing and calling your own procedure is something you will reuse all over Unit 3. Getting comfortable with calls now makes topics like writing procedures, using libraries, and building simulations much easier.

Key Takeaways

  • A procedure is a named group of instructions that may take parameters and may return a value. Different languages call it a method or a function.
  • Parameters are the input variables in a procedure's definition. Arguments are the actual values you pass when you call it.
  • Arguments match parameters by position: the first argument fills the first parameter, the second fills the second, and so on.
  • Calling a procedure pauses the normal top-to-bottom flow, runs the procedure's statements, then returns control to the line right after the call.
  • RETURN(expression) sends a value back to the call site and ends the procedure early; use result ← procName(arg1, arg2, ...) to store that returned value.
  • A procedure can take zero or more arguments, so not every procedure needs parameters.

How AP Pseudocode Represents Procedures

The exam reference sheet uses specific notation for defining and calling procedures. You do not have to memorize a real language's syntax, but you do need to read this notation fluently.

To define a procedure:

</>Code
PROCEDURE procName(parameter1, parameter2, ...)
{
    <block of statements>
}

To define a procedure that sends back a value:

</>Code
PROCEDURE procName(parameter1, parameter2, ...)
{
    <block of statements>
    RETURN(expression)
}

To call a procedure:

</>Code
procName(arg1, arg2, ...)

To call a procedure and store what it returns:

</>Code
result ← procName(arg1, arg2, ...)

When the call runs, arg1 is assigned to parameter1, arg2 is assigned to parameter2, and so on. The reference sheet also gives you DISPLAY(expression) to show a value followed by a space, and INPUT() to accept a value from the user and return it.

Parts of a Procedure

Here is a simple program that sums two numbers without a procedure:

</>Code
first_number = 5
second_number = 7
sum_value = first_number + second_number
print (sum_value)

If you wanted to sum several different pairs of numbers, you would have to rewrite these lines over and over. A procedure fixes that. Here is the same idea written as a function in Python:

</>Code
def summing_machine(first_number, second_number):
  print (first_number + second_number)

The names inside the parentheses, first_number and second_number, are the parameters. Parameters are the input variables a procedure uses to do its job. A procedure does not always need parameters; some take zero arguments.

When you call a procedure, the program runs the lines inside it as if they were written out at that spot. After it finishes, the program goes back to reading code in order from the line right after the call. The actual values you pass in when calling are the arguments:

</>Code
def summing_machine(first_number, second_number):
  print (first_number + second_number)

summing_machine(5, 7)
# In this example, 5 and 7 are the arguments.

Here 5 is assigned to first_number and 7 is assigned to second_number, matching by position.

Returning a Value

Sometimes you want a procedure to hand back a result instead of just displaying it. A return statement does that. It returns the value of an expression to the point where the procedure was called, and you can store or reuse that value:

</>Code
def summing_machine(first_number, second_number):
  value = first_number + second_number
  return (value)

answer = summing_machine(5, 7)
print (answer)

# You can manipulate the returned value too.
print (answer + 1)

In AP Pseudocode, you assign that returned value to a variable with the arrow operator, like answer ← summing_machine(5, 7). A RETURN statement also ends the procedure immediately, so any statements after it inside the procedure do not run.

How to Use This on the AP Computer Science Principles Exam

Code Tracing

Most procedure-call questions ask you to determine the result or effect of a call. Work through them in order:

  • Match each argument to its parameter by position.
  • Run the procedure's statements using those values.
  • If you hit a RETURN, stop running the procedure and send that value back.
  • Continue from the line right after the original call.

Display vs Return

Watch the difference between displaying and returning. DISPLAY(expression) shows a value as output but does not give the call a value you can store. RETURN(expression) gives the call a value you can assign with result ← procName(...) or use in a larger expression. A question may show a procedure that returns a value but never stores or displays it, which means nothing actually appears as output.

Create Performance Task

When you build your own program, writing a procedure with at least one parameter is a strong way to manage complexity and reuse code. Make sure you can explain in plain language what your procedure does and how its parameters change its behavior, since being able to describe how a procedure works is part of showing you understand your own code.

Common Misconceptions

  • Parameters and arguments are not the same thing. Parameters are the placeholder variables in the definition; arguments are the real values you pass in when you call.
  • Argument order matters. Values fill parameters by position, so swapping the order of arguments can change the result.
  • RETURN and DISPLAY are different. RETURN sends a value back to the caller; DISPLAY just shows output on the screen. A returned value is lost if you do not store or use it.
  • Calling a procedure does not skip the rest of your program. Control returns to the line right after the call once the procedure finishes.
  • A procedure does not have to take parameters. Procedures can take zero or more arguments.
  • Code after a RETURN inside the same procedure does not run, because RETURN ends the procedure right away.

Vocabulary

The following words are mentioned explicitly in the College Board Course and Exam Description for this topic.

Term

Definition

argument

The actual values passed to a procedure when it is called, which correspond to the procedure's parameters.

flow of control

The order in which statements are executed in a program, including how control transfers to and from procedures.

parameter

Variables in a procedure that allow it to accept different input values, enabling the procedure to be generalized and reused with a range of inputs.

procedure

A named block of reusable code that performs a specific task and can be called multiple times throughout a program.

procedure call

A statement that executes a named procedure, interrupting sequential execution and transferring control to the procedure.

return values

Values that a procedure sends back to the point where it was called.

sequential execution

The execution of programming statements in the order they appear, one after another.

Frequently Asked Questions

What is a procedure in AP Computer Science Principles?

A procedure is a named group of programming instructions that may take parameters and may return a value. Other programming languages may call the same idea a function or method.

What is the difference between parameters and arguments?

Parameters are the input variables listed in a procedure definition. Arguments are the actual values passed into the procedure when it is called, and they match parameters by position.

What happens when a procedure is called?

A procedure call pauses the normal sequence of statements, runs the statements inside the procedure, and then returns control to the line immediately after the call.

How do you call a procedure in AP pseudocode?

The AP reference sheet uses procName(arg1, arg2, ...) to call a procedure. If the procedure returns a value, you can store it with result <- procName(arg1, arg2, ...).

What is the difference between RETURN and DISPLAY?

RETURN sends a value back to the point where the procedure was called. DISPLAY shows a value as output but does not give the procedure call a value to store or reuse.

How should I trace procedure calls on the AP CSP exam?

Match arguments to parameters in order, run the procedure statements with those values, stop if you reach RETURN, and then continue from the line after the original call.

Pep mascot
Upgrade your Fiveable account to print any study guide

Download study guides as beautiful PDFs See example

Print or share PDFs with your students

Always prints our latest, updated content

Mark up and annotate as you study

Click below to go to billing portal → update your plan → choose Yearly→ and select "Fiveable Share Plan". Only pay the difference

Plan is open to all students, teachers, parents, etc
Pep mascot
Upgrade your Fiveable account to export vocabulary

Download study guides as beautiful PDFs See example

Print or share PDFs with your students

Always prints our latest, updated content

Mark up and annotate as you study

Plan is open to all students, teachers, parents, etc
report an error
description

screenshots help us find and fix the issue faster (optional)

add screenshot