Quiz 6 Flashcards

1
Q

If the formal parameter list of a function is empty, the parentheses after the function name are not needed.

A) True
B) False
A

False

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

In C++, a function prototype is the function heading without the body of the function.:
A) True
B) False

A

True

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

In creating C++ functions, you must be concerned with the function itself and how it interacts with other functions, such as main().
A) True
B) False

A

True

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

Calling a function places a certain amount of overhead on a computer.

A) True
B) False
A

True

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

The output of the statement:

cout &laquo_space;pow(2.0, pow(3.0, 1.0)) &laquo_space;endl;

is ____.

A) 6.0

B) 7.0

C) 8.0

D) 9.0

A

8.0

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

The output of the statement: cout &laquo_space;pow(3.0, 2.0) + 5 &laquo_space;endl; is ____.
Question options:

A) 11.0

B) 12.0

C) 13.0

D) 14.0

A

14.0

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

What value is returned by the following return statement?

int x = 5;

return x + 1;

A) 0

B) 5

C) 6

D) 7

A

6

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

The standard header file for the abs(x)function is ____.
Question options:

A) <cmath></cmath>

B) <ioinput></ioinput>

C) <cctype></cctype>

D) <cstdlib></cstdlib>

A

A) <cmath></cmath>

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

Given the following function prototype:

int test(float, char);

which of the following statements is valid?

A) cout &laquo_space;test(12, &);

B) cout &laquo_space;test(“12.0”, ‘&’);

C) int u = test(5.0, ‘*’);

D) cout &laquo_space;test(‘12’, ‘&’);

A

C) int u = test(5.0, ‘*’);

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

Given the function prototype:

float test(int, int, int);

which of the following statements is legal?

A) cout &laquo_space;test(7, test(14, 23));

B) cout &laquo_space;test(test(7, 14), 23);

C) cout &laquo_space;test(14, 23);

D) cout &laquo_space;test(7, 14, 23);

A

D) cout &laquo_space;test(7, 14, 23);

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

Which statement below about prototypes and headers is true?
Question options:

A) Parameter names must be listed in the prototype, but not necessarily in the header.

B) Prototypes end with a semicolon, but headers do not.

C) Headers should come before prototypes.

D) Headers end with a semicolon, but prototypes do not.

A

B) Prototypes end with a semicolon, but headers do not.

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

Functions that do not have a return type are called ____ functions.

A) zero

B) null

C) void

D) empty

A

void

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

Given the following function:

int strange(int x, int y)
{
if (x > y)
return x + y;
else
return x – y;

}

what is the output of the following statement?

cout &laquo_space;strange(4, 5) &laquo_space;endl;

A) -1

B) 1

C) 9

D) 20

A

-1

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

Given the following function prototype:

int myFunc(int, int);

which of the following statements is valid? Assume that all variables are properly declared.

Question options:

A) cin&raquo_space; myFunc(y);

B)cout«myFunc(myFunc(7, 8), 15);

C) cin&raquo_space; myFunc(‘2’, ‘3’);

D) cout «myFunc(myFunc(7), 15);

A

B)cout«myFunc(myFunc(7, 8), 15);

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

The following return statement returns the value 10.

return 10, 16;

A) True
B) False
A

False

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

Once you write and properly debug a function, you can use it in the program (or different programs) again and again without having to rewrite the same code repeatedly.

A) True
B) False
17
Q

You should make all your variables global if possible.
A) True
B) False

18
Q

In C++, a function is allowed to change the contents of variables declared in other functions.
A) True
B) False

19
Q

The statement: return 37, y, 2 * 3; returns the value ____.

A) 2

B) 3

C) y

D) 6

20
Q

Given the function prototype:

double testAlpha(int u, char v, double t);

which of the following statements is legal?

A) cout &laquo_space;testAlpha(5, ‘A’, 2);

B) cout &laquo_space;testAlpha( int 5, char ‘A’, int 2);

C) cout &laquo_space;testAlpha(‘5.0’, ‘A’, ‘2.0’);

D) cout &laquo_space;testAlpha(5.0, “65”, 2.0);

A

A) cout &laquo_space;testAlpha(5, ‘A’, 2);

21
Q

A variable or expression listed in a call to a function is called the ____.

A) formal parameter

B) actual parameter

C) data type

D) type of the function

A

B) actual parameter

22
Q

A variable listed in a header is known as a(n) ____ parameter.

A) actual

B) local

C) formal

D) function

23
Q

A function prototype is ____.

A) a definition, but not a declaration

B) a declaration and a definition

C) a declaration, but not a definition

D) a comment line

A

C) a declaration, but not a definition

24
Q

The data type of a variable in a return statement must match the function type.

A) True
B) False
25
Q

The following function heading in a C++ program is valid:

int funcExp(int u, char v, float g)

A) True
B) False