Ch_6_Functions Flashcards

1
Q

Modular Programming

A

Breaking a program into a set of manageable functions for modules. Sometimes called Divide and Conquer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Function

A

A collection of statements that performs a specific task.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Function Call

A

A statement that causes a function to execute.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Function Definition

A

The statements that make up the function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

The parts of every Function definition.

A
  • Name
  • Parameter List
  • Body
  • Return Type

Note: The Function Header includes the Return Type, Name, and Parameter List

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Void Functions

A

Functions that do not return a value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Function Prototype

A

Eliminates the need to place a function definition before all calls to the function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Arguments

A

Values sent into a function by the program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Parameter

A

A special variable that holds a value being passed as an argument into a function.

The parameters of a function are local variables. Their scope is limited to the body of the function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Value Returning Functions

A

Functions that return a value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Local Variable

A

Variables defined inside of a function that are local to that function. They are hidden from statements in other functions, which normally cannot access them.

Not automatically initialized, as global variables are.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Global Variable

A

Any variable defined outside of all the functions in the program, including main.

Automatically initialized to zero.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Global Constant

A

A constant variable available to every function in the program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Static Local Variables

A

Are not destroyed when the function returns.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Default Arguments

A

Are passed to parameters automatically if no argument is provided in the function call.

Notes:
- The value of a default argument must be a literal value or a named constant.
- When an argument is left out of a function call (because it has a default value), all the arguments that come after it must also be left out.
- When a function has a mixture of parameters both with and without default arguments, the parameters with default arguments must be last.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Reference Variable

A

A variable that references the memory location of another variable. Any change made to the reference.

An ampersand must be used in the prototype and header.

The reference must be made to a variable, and not literal, constant, or expression.

17
Q

Three common instances when reference parameters are used.

A
  • When data values being input in a function need to be known by the calling function.
  • When a function must change existing values in the calling function.
  • When a file stream object is passed to a function.
18
Q

Overload Functions

A

Functions that have the same name but different parameter lists.

19
Q

Function Signature

A

The name of the function and the data types of the function’s parameters in the proper order.

20
Q

Exit Function exit()

A

Causes a program to terminate, regardless of which function or control mechanism is executing.

The cstdlib header file is required

21
Q

EXIT_SUCCESS

A

A named constant used with the exit() function to indicate a successful program termination.

22
Q

EXIT_FAILURE

A

A named constant used with the exit() function to indicate a problem has occurred.

23
Q

Stub

A

A dummy function that is called instead of the actual function it represents. It usually displays a test message acknowledging that it was called, nothing more.

24
Q

Driver

A

A program that tests a function by simply calling it.