Use abstraction to manage complexity in a program.
Determine the result of code segments.
Learning Objective:
For procedure calls:
a. Write statements to call procedures
b. Determine the effect of the procedure call
AAP-3.A.1
A procedure is a named group of programming
instructions that may have parameters and
return values.
AAP-3.A.2
Procedures are referred to by different names,
such as method or function, depending on the
programming language.
AAP-3.A.3
Parameters are input variables of a procedure.
Arguments specify the values of the
parameters when a procedure is called.
AAP-3.A.4
A procedure call interrupts the sequential
execution of statements, causing the program
to execute the statements within the procedure
before continuing. Once the last statement
in the procedure (or a return statement)
has executed, flow of control is returned to
the point immediately following where the
procedure was called.
AAP-3.A.5
The exam reference sheet provides
procName(arg1, arg2, ...)
as a way to call
Text:
PROCEDURE procName(parameter1,
parameter2, ...)
{
<block of statements>
which takes zero or more arguments; arg1
is assigned to parameter1, arg2 is
assigned to parameter2, and so on.
The exam reference sheet provides the
procedure
Text:
DISPLAY(expression) to display the value of expression, followed
by a space.
The exam reference sheet provides the
Text:
RETURN(expression) statement, which is used to return the flow
of control to the point where the procedure
was called and to return the value of
expression.
The exam reference sheet provides
result procName(arg1,
arg2, ...)
to assign to result the “value of the
procedure” being returned by calling
Text:
PROCEDURE procName(parameter1,
parameter2, ...)
{
<block of statements>
RETURN(expression)
AAP-3.A.9
The exam reference sheet provides procedure
Text:
INPUT()
Block:
INPUT
which accepts a value from the user and
returns the input value.