Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
6 views7 pages

Function (Supplement Notes)

The document outlines key concepts related to functions in C++, including their definitions, types, and usage. It explains the differences between value-returning and void functions, the importance of function prototypes, and the scope of variables. Additionally, it covers the syntax for defining and calling functions, as well as the rules for parameters and return statements.

Uploaded by

Ahmed Al-nasheri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views7 pages

Function (Supplement Notes)

The document outlines key concepts related to functions in C++, including their definitions, types, and usage. It explains the differences between value-returning and void functions, the importance of function prototypes, and the scope of variables. Additionally, it covers the syntax for defining and calling functions, as well as the rules for parameters and return statements.

Uploaded by

Ahmed Al-nasheri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Function Supplement Notes

Meaning/Answer Term/Question
functions _________ enable you to divide a program into manageable tasks.

standard function To use a ________________ you must: know the name of the header file
that contains the function's specification, include that header file in the
program, and know the name and type of the function and number and
types of the parameters
value-returning functions The two types of user-defined functions are:
and void functions
formal parameters Variables defined in a function heading are called
predefined The C++ system provides the standard functions also known as
______________ functions
actual parameters Expressions, variables, or constant values used in a function call are called
function call In a __________, the number of actual parameters and their types must
match with the formal parameters in the order given.
actual parameter list To call a function, use its name together with the __________________
expression or an output A value-returning function returns a value. Therefore, a value-returning
statement function is used (called) in either an __________________________ or as
a parameter in a function call.
syntax The general __________ of a user-defined function is :
functionType functionName (formal parameter list)
{
statement(s);
}
function heading The line functionType functionName (formal parameter list) is called the
_________________ (or function header). Statements enclosed between
braces are called the body of the function.
definition The function heading and the body of the function are called the
________ of the function.
parentheses You still need the empty _____________________ in both the function
heading and the function call if a function has no parameters.
return statement A value-returning function returns its value via the _________________.
exits When a return statement executes in a function, the remaining
statements are skipped and the function _____________.
one A return statement return only _____ value.
function prototype A _____________________________ is the function heading without the
body of the function (ends with the semicolon).
prototype A function ______________ announces the function type, as well as the
type and number of parameters, used in the function.
variables In a function prototype, the names of the _______ in the formal
parameter list are optional.
function call Function prototypes help the compiler correctly translate each
_____________.
function main In a program, function prototypes are places before every function
definition, including the definition of the _______________.
prototypes When you use function _________, user-defined functions can appear in
any order in the program.
function main When the program executes, the execution always begins with the first
statement in the ____________.
true Functions execute only when they are called. (true/false?)
function A call to a function transfers control from the caller to the called
___________.
actual In a function call statement, you specify only the __________ parameters,
not their data type or the function type.
caller When a function exits, control goes back to the _______.
void A function that does not have a data type is called a ________ function.
void function A return statement without any value can be used in a _______________.
If a return statement is used in a void function, it is typically used to exit
the function early.
void The heading of a void functions starts with the word _______.
reserved In C++, void is a _______ word.
void A ______ function may or may not have parameters.
stand A call to a void function is a ______-alone statement.
actual To call a void function, you use the function name together with the
__________ parameters in a stand-alone statement.
reference There are two types of formal parameters: value parameters and
_________ parameters.
value A ______ parameter receives a copy of its corresponding actual
parameter.
reference A _______ parameter receives the address (memory location) of its
corresponding actual parameter.
constant The corresponding actual parameter of a value parameter is an
expression, a variable, or a _______ value.
reference A constant value cannot be passed to a _______ parameter.
variable The corresponding actual parameter of a reference parameter must be a
__________.
reference parameter When you include & after the data type of a formal parameter, the formal
parameter becomes a ________________.
reference The stream variables should be passed by ________ to a function.
reference If a formal parameter needs to change the value of an actual parameter,
in the function heading, you must declare this formal parameter a ______
parameter.
accessible The scope of an identifier refers to those parts of the program where it is
__________.
local Variables declared within a function (or block) are called _______
variables.
global Variables declared outside of every function definition (and block) are
called _______ variables.
identifier The scope of a function name is the same as the scope of an _________
declared outside of any block.
identifier Scope rules in this chapter are found in section, Scope of an ________.
definitions C++ does not allow the nesting of function _______.
exit An automatic variable is a variable for which memory is allocated on
function (or block) entry and deallocated on function (or block) _____.
static A ________ variable is a variable for which memory remains allocated
throughout the execution of the program.
static By default, global variables are ______ variables.
false In C++, a function can not be overloaded. (true/false?)
position Two functions are said to have different formal parameter lists if both
functions have a different number of formal parameters or the same
number of formal parameters and the data types of the formal
parameters, in the order listed, differ in at least one ________.
formal The signature of a function consists of the function name and its
________ parameter list.
formal Two functions have difference signatures if they have either different
names or different _______ parameter lists.
function If a function is overloaded, then in a call to that function the formal
parameter list of the function determines which ______ to execute.
true C++ allows functions to have default parameters. (true/false?)
default If you do not specify the value of a default parameter, the ______ value is
used for that parameter.
right Suppose a function has more than one default parameter. In a function
call, if a value to a default parameter is not specified, then you must omit
all arguments to its right or left?
default All of the _____ parameters must be the far-right parameters of the
function.
function Default values can be constants, global variables, or ________ calls.
default The calling function has the option of specifying a value other than the
default for any ________ parameter.
reference You cannot assign a constant value as a default value to a _______
parameter.

What are Functions also Like ?


Miniature programs

What are Functions also Called ?


Modules

What do Functions Enable you to do ?


Divide a program into manageable tasks

What kind of Functions does the C++ System provide ?


Standard, predefined functions

What are the Three Things you Must do to Use a Standard Function ?
- Know the name of the header file that contains the function's specification
-Include that header file in the program
- Know the name and type of the function, and know the number and types of parameters (arguments)

What are the Two Types of User-Defined Functions ?


Value-returning functions and void functions

What are Formal Parameters ?


Variables defined in a function heading

What are Actual Parameters ?


Expressions, variables, or constant values used in a function call

In a Function Call, What Must the Number of Actual Parameters and Their Type Match ?
Formal parameters in the order given

How do you Call a Function ?


Use its name together with the actual parameter list

What does a Value-returning Function Return ?


Value

Where is a Value-returning Function is used in ?


In an Expression or an output statement / As a Parameter in a function call

What is the General Syntax of a User-Defined Function?


functionType functionName ( formal parameter list )
{
statements
}

What is the Function Heading Syntax ?


functionType functionName ( formal parameter list )

What is a Body of the Function ?


Statements enclosed between braces

What do you Need when a Function has No Parameters?


You always need the empty parentheses in both the function heading and the function call

How does A Value-Returning Function Return its Value ?


Via return statement

What are the Rules for the Multiple return Statements ?


Functions can have more than one return statement. However, whenever a return statement executes
in a function, the remaining statements are skipped and the function exits.

How many Values can a Return Statement Return ?


Only One Value

What is a Function Prototype ?


Function heading without the body of the function; the function prototype ends with the semicolon.

In a Function Prototype, What is Optional ?


Names of the variables in the formal parameter

What are the Three Things the Function Prototype Announces to Be Used in the Function?
- Function type
- Type of parameters
- Number of parameters

How does the Function Prototype Help the Compiler ?


Correctly translate each function call

In a Program, What are all Function Prototypes are Placed before ?


Every function definition, including the definition of the function main

When You Use Function Prototypes, User-Defined Function Can Appear in __ .


Any order in the program

When the Program Executes, What does the Execution Always Begins With ?
First statement in the function main

Only When do User-Defined Functions Execute ?


When they are called
What Does a Call to a Function Transfer ?
Control from the caller to the called function

What Do You Specify in a Function Call Statement?


Only the actual parameters, not their data type or the function type

What Does the Control Do When a Function Exits?


Goes back to the caller

What is a Void Function


A function that does not have a data type

What can A Return Statement Without Any Value be Used in ?


Void Function

What Does a Return Statement in a Void Function Typically Do?


Exit the function early

What is the Heading of a Void Function ?


Starts with the word void

What Kind of Word is void in C++ ?


Reserved

What can a Void Function May or May not have ?


Parameters

What is a Stand-Alone Statement ?


Call to a void function

How do you Call a Void Function ?


Use the function name together with the actual parameters in a stand-alone statement

What are the Two Types of Formal Parameters ?


Value parameters and reference parameters

What Does a Value Parameter Receive ?


Copy of its corresponding actual parameter

What Does a Reference Parameter Receive ?


Address (Memory Location) of its corresponding actual parameter

What are the Three Things a Corresponding Actual Parameter of a Value Parameter is ?
Expression, variable, or constant value
What can a Constant Value not be Passed unto ?
Reference Parameter

What Must the Corresponding Actual Parameter of a Reference Parameter be?


Variable

What Happens When You Include the & after the Data Type of a Formal Parameter?
The formal parameter becomes a reference parameter

What should the Stream Variables be Passed by and to?


Reference / Function

What Must You Do if a Formal Parameter Needs to Change the Value of an Actual Parameter?
Declare this formal parameter as a reference parameter in the function heading

What Does the Scope of an Identifier Refer to?


Those parts of the program where the identifier is accessible

What are Local Variables ?


Variables declared within the function or block

What are Global Variables ?


Variables declared outside of every function definition and block

What is the Scope of a Function Name the Same as ?


Scope of an identifier declared outside of any block

What Does C++ Not Allow the Nesting of ?


Function Definitions

You might also like