C++ Functions Flashcards
IT IS A SET OF INSTRUCTIONS THAT IS DESIGNED TO PERFORM A SPECIFIC TASK.
Function
A PROGRAM TO BE BROKEN INTO SMALL TASKS.
Function
THESE ARE SUBPROGRAMS THAT DO NOT EXECUTE UNTIL THEY CALLED
Function
TYPES OF FUNCTION
- PRE-DEFINED FUNCTIONS
- USER DEFINED FUNCTIONS
- ALREADY BEEN DEFINED AS A PART OF THE LANGUAGE
PRE-DEFINED FUNCTIONS
- FUNCTIONS CREATED BY A USER.
USER DEFINED FUNCTIONS
RETURN STATEMENT
CAUSES THE VALUE TO BE RETURNED TO THE CALLING FUNCTION.
WHAT IS A VALUE RETURNING FUNCTION?
Value returning functions are used when only one result is returned and that result is used directly in an expression.
a function declaration that does not include the body of the function.
FUNCTION PROTOTYPE
FUNCTION DEFINITION
A FUNCTION DECLARATION THAT INCLUDES THE BODY OF THE FUNCTION. IT IS THE ACTUAL CODE OF THE FUNCTION AND ALWAYS OUTSIDE THE main( ) FUNCTION.
IT IS USED WHEN INPUT/OUTPUT IS PERFORMED AND MORE THAN ONE VALUE IS TO BE RETURNED BY MODIFYING ONE OR MORE PARAMETERS RATHER THAN USING A RETURN STATEMENT.
VOID FUNCTION
A VOID FUNCTION DOES NOT RETURN A VALUE TO ITS CALLER.
VOID FUNTION
LOCAL VARIABLE
A variable declared within a block and not accessible outside of that block. When the function ends (returns) all of its local variables are destroyed.
A variable declared outside of all the functions in a program.
GLOBAL VARIABLE
When you send a parameter to a function and its value will NOT BE MODIFIED, use a value parameter. When the function is CHANGING the actual parameter, such as in an input function, use a reference parameter.
PARAMETERS