Chapter 6 Flashcards

1
Q

The _________ is the part of a function definition that shows the function name, return type, and parameter list

A

header

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

If a function doesn’t return a value, the word _________ will appear as its return type.

A

void

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

Either a function’s _________ or its _________ must precede all calls to the function.

A

definition, prototype

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

Values that are sent into a function are called _________.

A

arguments

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

Special variables that hold copies of function arguments are called _________.

A

parameters

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

When only a copy of an argument is passed to a function, it is said to be passed by

A

value

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

A(n) _________ eliminates the need to place a function definition before all calls to the function

A

prototype

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

A(n) _________ variable is defined inside a function and is not accessible outside the
function

A

local

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

_______ variables are defined outside all functions and are accessible to any function within their scope.

A

global

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

________ variables provide an easy way to share large amounts of data among all the
functions in a program.

A

global

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

Unless you explicitly initialize global variables, they are automatically initialized to _________

A

0

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

If a function has a local variable with the same name as a global variable, only the
_________ variable can be seen by the function.

A

local

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

________ local variables retain their value between function calls.

A

static

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

The _________ statement causes a function to end immediately.

A

return

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

________ arguments are passed to parameters automatically if no argument is provided in the function call

A

default

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

When a function uses a mixture of parameters with and without default arguments, the
parameters with default arguments must be defined _________

A

last

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

The value of a default argument must be a(n) _________.

A

constant

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

When used as parameters, _________ variables allow a function to access the parameter’s
original argument

A

reference

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

Reference variables are defined like regular variables, except there is a(n) _________ in front of the name

20
Q

Reference variables allow arguments to be passed by _________.

21
Q

The _________ function causes a program to terminate.

22
Q

Two or more functions may have the same name, as long as their _________ are different.

A

parameter lists

23
Q

Functions should be given names that reflect their purpose.

24
Q

Function headers are terminated with a semicolon.

25
Function prototypes are terminated with a semicolon.
true
26
If other functions are defined before main, the program still starts executing at function main
true
27
When a function terminates, it always branches back to main, regardless of where it was called from.
false
28
Arguments are passed to the function parameters in the order they appear in the function call
true
29
The scope of a parameter is limited to the function which uses i
true
30
Changes to a function parameter always affect the original argument as well.
false
31
In a function prototype, the names of the parameter variables may be left out.
true
32
Many functions may have local variables with the same name.
true
33
Overuse of global variables can lead to problems.
true
34
Static local variables are not destroyed when a function returns.
true
35
All static local variables are initialized to −1 by default.
false
36
Initialization of static local variables only happens once, regardless of how many times the function in which they are defined is called
true
37
When a function with default arguments is called and an argument is left out, all arguments that come after it must be left out as well
true
38
It is not possible for a function to have some parameters with default arguments and some without
false
39
The exit function can only be called from main.
false
40
A stub is a dummy function that is called instead of the actual function it represents.
true
41
void total(int value1, value2, value3) { return value1 + value2 + value3; }
The data type of value2 and value3 must be defined. The function is declared void but returns a value.
42
double average(int value1, int value2, int value3) { double average; average = value1 + value2 + value3 / 3; }
The assignment statement should read: average = (value1 + value2 + value3) / 3.0;
43
void area(int length = 30, int width) { return length * width }
width should have a default argument value The function is defined void but returns a value
44
void getValue(int value&) { cout << "Enter a value: "; cin >> value&; }
The parameter should be defined as: int &value The cin statement should read: cin >> value;
45
(Overloaded functions) int getValue() { int inputValue; cout << "Enter an integer: "; cin >> inputValue; return inputValue; } double getValue() { double inputValue; cout << "Enter a floating-point number: "; cin >> inputValue; return inputValue; }
The functions must have different parameter lists.