M7 Flashcards
a group of statements that is
executed when it is called from some point of the
program
function
a self-contained block of code with
a specific purpose. It has a name that is used to
identify and call it for execution.
function
a subprogram that acts on data and
often returns a value.
function
functions are easier to:
maintain, update, and debug
The program that calls a
function is often referred
to as the
calling
program.
One function that every
C++ program possesses:
int main()
is a programmed routine that
has its parameters set by the user of the system
user-defined function
are functions that perform
specific tasks within a larger system, such as a database
or spreadsheet program.
User defined functions
If the function returns a value then the type of that value must be
specified in
return_type
follows the same rules of composition as
identifiers
function_name
lists the formal parameters of the function
together with their types.
parameter_list
are definitions of variables that are used in the
function_implementation.
local_definitions
consists of C++ executable
statements that implement the effect of the function.
function_implementation
If the function does not return a value then the return_type
must be
void.
. These variables have no meaning outside
the function.
local_definitions
There are two main parts of the function:
The function header and the function body.
What ever is written with in { } in the above
example is the
body of the function.
provides the basic information about a function which
tells the compiler that the function is used correctly or not.
function prototype
contains the same information as the function header
contains.
function prototype
can be used to check the calls to the function for the
proper number of parameters and the correct types of
parameters.
function prototype
A function that can be made to return a single value to
the calling program is referred to as
non-void function.
A function that is written to perform specific task
and return multiple values to calling program are
called
void functions.
are variables/values used within the function call
Actual arguments
are variables used within
the function header that receives the copy of the actual argument
values.
formal parameters
This means that when calling a function with parameters,
what we have passed to the function were copies of their
values but never the variables themselves.
pass by values
somehow passing the variable
itself to the function
pass by reference
A function that calls itself is known
as a
recursive function
is a function call in
which the function being called is
the same as the one making the
call.
Recursive call
is a programming
technique in which procedures and
functions call themselves.
Recursion
A definition in which something is defined in terms of
smaller version of itself.
recursive definition
The case for which the solution
can be stated non-recursively
The case for which the answer
is explicitly known
base case
The case for which the solution
is expressed in smaller version
of itself. Also known as
recursive case.
general case
Which is more effective while calling the functions?
call by reference
What are mandatory parts in the function declaration?
return type, function name
Where does the execution of the program starts?
main function