Module 1 Flashcards
FUNCTIONS & FUNCTIONS PARAMETERS
- in programming, are collections of statements that work together to complete tasks.
Functions
- Library Functions
- User Defined Functions
Types of Functions
- may return a value or perform an action without returning a value (void functions)
Function Structure
- Declarations of functions before their actual use in program
Function Prototypes
- invoking a user-defined function to execute its code
- passing arguments to the function if required.
Function Call
- actual implementation of the function, including its body.
- contains parameters if any, local variables, and return statements.
Function
- Function with no argument and no return value
- Function with no argument but returns a value
- Function with argument but no return value
- Function with argument and return value
Types of User Defined Functions
- also known as non-value returning functions
- stand-alone statement
Void Functions
variables created within a function.
Local Variables
- act as variables inside the function.
- multiple parameters separated by commas are allowed.
- are specified after the function name, inside the parenthesis
Function Parameters
variable in the declaration of function
Parameter
actual value of this variable that gets passed to function
Argument
- functions without a returning value.
- return statement gathers value from the function and returns it to the caller.
Void Functions
- values specified in function declarations
- assigned by the compiler if no value is specified in the function call.
- default value can be overridden by passing a value
Default Arguments
- Functions can accept parameters and return values.
- Parameters specified in function prototypes and definitions.
- Arguments passed to functions during function calls.
User Defined Functions with Parameters
- Occurs when a function name is used for multiple tasks with different arguments.
- Same function name but different parameters.
Function Overloading
return_type function_name(parameter1_type parameter1_name, parameter2_type parameter2_name, …);
Syntax for function prototype with parameters:
return_type function_name(parameter1_type parameter1_name, parameter2_type parameter2_name, …) {
// Function body
}
Syntax for function definition with parameters:
function_name(argument1, argument2, …);
Syntax for passing arguments to a function: