06.Functions

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/18

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

19 Terms

1
New cards

What is a function in programming?

A self-contained collection of statements that performs a specific task, which may have inputs and outputs.

2
New cards

What does modular programming entail?

Dividing a problem into smaller, manageable pieces and solving each piece as sub-routines.

3
New cards

What is procedural programming?

A programming paradigm that expresses the logic of the program as a sequence of statements, often called functions.

4
New cards

What are function inputs?

Variables or values passed into a function, which the function uses to perform its actions.

5
New cards

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.

6
New cards

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.

7
New cards

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.

8
New cards

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.

9
New cards

What are the benefits of using functions in programming?

Improved code readability, easier debugging, code reusability, and encapsulation of behavior.

10
New cards

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.

11
New cards

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.

12
New cards

When should you use function overloading?

When you want to perform the same operation but with different input types or different numbers of inputs.

13
New cards

What can be included in the function signature?

The function's name, parameter types, and return type.

14
New cards

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.

15
New cards

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.

16
New cards

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.

17
New cards

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.

18
New cards

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.

19
New cards

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.