1/18
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is a function in programming?
A self-contained collection of statements that performs a specific task, which may have inputs and outputs.
What does modular programming entail?
Dividing a problem into smaller, manageable pieces and solving each piece as sub-routines.
What is procedural programming?
A programming paradigm that expresses the logic of the program as a sequence of statements, often called functions.
What are function inputs?
Variables or values passed into a function, which the function uses to perform its actions.
What is the difference between arguments and parameters?
Arguments are the actual values passed into a function when called; parameters are the variables defined in the function signature that receive these values.
What is pass-by-value?
A method of passing arguments to functions where a copy of the argument's value is made, and changes to the parameter do not affect the original argument.
What is pass-by-reference?
A method of passing arguments to functions where a reference to the actual variable is passed, allowing the function to modify the original variable.
What is a void-returning function?
A function that does not return a value; it may perform an action but does not provide a result.
What are the benefits of using functions in programming?
Improved code readability, easier debugging, code reusability, and encapsulation of behavior.
What is the purpose of a function prototype?
A declaration of a function that informs the compiler about the function's name, return type, and parameters, without providing the body.
What is a static local variable?
A variable defined within a function that maintains its value between function calls and is only visible within that function.
When should you use function overloading?
When you want to perform the same operation but with different input types or different numbers of inputs.
What can be included in the function signature?
The function's name, parameter types, and return type.
Why might you use default arguments in a function?
To allow certain parameters to have default values, reducing the need for users to specify every argument during function calls.
How do function calls affect the call stack?
Calling a function adds a new frame to the stack for parameters and local variables; returning removes the frame.
What is global variable and its drawback?
A variable declared outside any function, accessible globally, which can lead to hard-to-read code and debugging issues.
What is the difference between local and global variables?
Local variables exist within a function's scope, while global variables are accessible throughout the entire program.
What is the significance of the return statement in a function?
It indicates the end of a function's execution and optionally provides a value back to the calling function.
What is encapsulation in the context of functions?
The concept that users of a function do not need to understand the internal workings of the function, only how to call it.