AP Computer Science Principles Flashcards: Calling Procedures
Written by AP Content Team, Verified for 2026 AP Exams, Last updated: May 2026
Review key ideas with interactive flashcards. This set includes 24 cards to help you master important concepts.
A procedure is defined as `PROCEDURE add(num1, num2) { RETURN(num1 + num2) }`. What is the result of the call `add(5, 3)`?
The result of the procedure call is the value 8.
Card 1 of 24
All Flashcards (24)
A procedure is defined as `PROCEDURE add(num1, num2) { RETURN(num1 + num2) }`. What is the result of the call `add(5, 3)`?
The result of the procedure call is the value 8.
What are the two main things to determine when analyzing a procedure call?
You must determine the result of the procedure call (what value it returns, if any) and its effect (what actions it performs, like displaying output).
What is the term for the action of writing a statement that causes a procedure to execute?
This action is known as calling a procedure or a procedure call.
What is a procedure?
A procedure is a named group of programming instructions that may have parameters and return values.
A procedure is defined as `PROCEDURE greet() { DISPLAY("Welcome!") }`. What is the effect of the call `greet()`?
The effect of the procedure call is that the text "Welcome!" is displayed to the user.
What is the sequential flow of these three lines of code?
1. `DISPLAY("Start")`
2. `myProc()`
3. `DISPLAY("End")`
First, "Start" is displayed. Then, the program executes all statements inside `myProc()`. Finally, after `myProc()` is finished, "End" is displayed.
In the procedure call `calculate(100, 0.05)`, what are `100` and `0.05`?
`100` and `0.05` are the arguments being passed to the procedure `calculate`.
What is the function of the `INPUT()` procedure on the exam reference sheet?
The `INPUT()` procedure accepts a value from the user and returns that input value to the program.
What does the notation `result ← procName(arg1, arg2, ...)` signify?
This notation signifies that the procedure `procName` is called with arguments, and the value it returns is assigned to the variable `result`.
Using the exam reference sheet's `DISPLAY` procedure, how would you show the text "Hello, World!"?
You would write the statement: `DISPLAY("Hello, World!")`.
Using the exam reference sheet notation, how do you assign the returned value of a procedure call `findMax(15, 20)` to a variable named `highestValue`?
The statement would be: `highestValue ← findMax(15, 20)`.
In the procedure definition `PROCEDURE calculate(base, rate)`, what are `base` and `rate`?
`base` and `rate` are the parameters of the procedure `calculate`.
What is the difference between a parameter and an argument?
A parameter is the variable in the procedure's definition, while an argument is the actual value passed into that parameter when the procedure is called.
Consider the procedure `PROCEDURE square(x) { RETURN(x * x) }`. What is the result of the statement `value ← square(4)`?
The procedure call `square(4)` returns 16, so the variable `value` will be assigned the value 16.
How does a procedure call affect the flow of control in a program?
A procedure call interrupts the sequential execution of statements, running the code inside the procedure before returning to the next statement in the main program.
What is the purpose of the `RETURN(expression)` statement from the exam reference sheet?
It returns the flow of control from the procedure to where it was called and sends back the value of the expression.
According to the exam reference sheet, how do you write a statement to call a procedure named `doSomething` that takes two arguments, `val1` and `val2`?
The procedure call would be written as `doSomething(val1, val2)`.
Can a procedure be called without any arguments?
Yes, a procedure can be defined to take zero arguments and can therefore be called without providing any.
When does the flow of control return to the main program after a procedure is called?
The flow of control returns to the main program after the last statement in the procedure is executed or when a specific return statement is encountered.
What are parameters?
Parameters are the input variables of a procedure, which are listed in the procedure's definition.
What are arguments?
Arguments are the specific values provided for a procedure's parameters when it is called.
Does every procedure call result in a value being returned?
No, a procedure may perform an action, such as displaying text, without returning a value.
What are other common names for a procedure?
Depending on the programming language, procedures are also commonly referred to as methods or functions.
Write a line of code to get input from a user and store it in a variable called `userName`.
Using the exam reference sheet notation, the code would be: `userName ← INPUT()`.