USER-DEFINED FUNCTIONS Flashcards

1
Q

To use a predefined function in a program, you need to know only the name of the function and how to use it.

A

False

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

A value-returning function returns only one value.

A

True

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

Parameters allow you to use different values each time the function is called.

A

True

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

When a return statement executes in a user-defined function, the function immediately exits.

A

True

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

A value-returning function returns only integer values.

A

False

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

When a return statement executes in a user-defined function, the function immediately exits.

A

True

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

A value-returning function returns only integer values.

A

False

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

A variable name cannot be passed to a value parameter

A

False

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

If a C++ function does not use parameters, parentheses around the empty parameter list are still required.

A

True

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

In C++, the names of the corresponding formal and actual parameters must be the same.

A

False

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

A function that changes the value of a reference parameter also changes the value of the actual parameter

A

True

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

Whenever the value of a reference parameter changes, the value of the actual parameter changes.

A

True

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

In C++, function definitions can be nested; that is, the definition of one function can be enclosed in the body of another function.

A

False

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

Using global variables in a program is a better programming style than using local variables, because extra variables can be avoided.

A

False

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

In a program, global constants are as dangerous as global variables.

A

False

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

The memory for a static variable remains allocated between function calls.

17
Q

The following is a valid C++ enumeration type:

enum romanNumerals {I, V, X, L, C, D, M}

18
Q

Given the declaration: enum cars {FORD, GM, TOYOTA, HONDA}; cars domesticCars = FORD;
the statement: domesticCars = domesticCars + 1; sets the value of domesticCars to GM

19
Q

The values in the domain of an enumeration type are called enumerators.

20
Q

The only arithmetic operations allowed on the enumeration type are increment and decrement.

21
Q

You can input the value of an enumeration type directly from a standard input device

22
Q

A function can return a value of an enumeration type.

23
Q

The following are legal C++ statements in the same block of a C++ program:
enum mathStudent {BILL, JOHN, LISA, RON, CINDY, SHELLY};
enum historyStudent {AMANDA, BOB, JACK, TOM, SUSAN};

24
Q

The following statement creates an anonymous type: enum {A, B, C, D, F} studentGrade;

25
A double type is an example of a simple data type.
True
26
A one-dimensional array is an example of a structured data type
True
27
Arrays can be passed as parameters to a function either by value or by reference
False
28
A function can return a value of type array
True
29
A function can return a value of type array
True
30
If an array index goes out of bounds, the program always terminates in an error
False
31
In C++, some aggregate operations are allowed for strings.
True
32
As parameters, two-dimensional arrays are passed either by value or by reference.
False
33
The declaration: char str = "Sunny Day"; declares str to be a string of an unspecified length.
False