Ch.4 Flashcards

(37 cards)

1
Q

In the function declaration shown, the mechanism used to call this function is known as:

double pow(double base, double exp);

A

call by value

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

If you need to write a function that will compute the cost of some candy, where each piece costs 25 cents, which would be an appropriate function declaration?

A

int calculateCost(int count);

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

What is the value of the following?

sqrt(sqrt(pow(2,4)));

A

2

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

Using namespace std; tells the compiler

A

where to get the definitions of certain objects (variables).

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

What is the output of the following program fragment?

cout ≤≤ static_cast ≤ float > (3/4) ≤≤ endl;

A

0.0

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

What is the output of the following program fragment?

cout ≤≤ static_cast ≤ double > (3)/4 ≤≤ endl;

A

0.75

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

Information Hiding is analogous to using

A

a black-box methodology.

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

Which of the following functions is a properly overloaded function of the following?

int doSomething(int first, float second);

A) int doSomething(int first, int second, float third);

B) int doSomething( int next, float last);

C) int doSome(int first, float second);

D) float doSomething(int first, float second);

A

int doSomething(int first, int second, float third);

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

If the variable x has the original value of 3.4, what is the value in x after the following?

cout << static_cast < int > (x);

A

3

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

When the function below is called, the ________ of the actual parameters is passed to the function definition.

double sqrt(double value);

A

value

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

If you have the following variable declaration in your program,

const int SIZE = 34;

then which of the following statements are legal?

A

cout << SIZE;

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

The functions pow( ), sqrt( ), and fabs( ) are found in which include file?

A

cmath

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

When overloading a function, what must be true?

A) The names should be different with the same number and/or types of parameters.

B) The names should be the same with the same number and/or types of parameters.

C) The names should be different with different number and/or types of parameters.

D) The names should be the same with different number and/or types of parameters.

A

The names should be the same with different number and/or types of parameters

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

When parameters are passed between the calling code and the called function, parameters and arguments are matched by

A

their relative positions in the parameter and argument lists

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

If you have the two functions as shown,

int someFunction(int value);

float someFunction(float value);

and a variable x, which is a double, which function is called by the following statement?

cout ≤≤ someFunction(x);

A

Nothing, it is a syntax error.

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

When a variable is local to a function, we say that it has ________ of the function.

17
Q

What is the value of x after the following code fragment executes?

float x = 36.0;

x = sqrt(x)

18
Q

The expression static_cast < double > (3) is called a

19
Q

What is the value returned by the following function?

int function( )

{

int value = 35;

return value + 5;

value += 10;

}

20
Q

What is the value of i after the following function call?

//function definition

int doSomething(int value)

{

value = 35;

return value;

value = 13

}

//fragment of main program

int i = 0;

cout << doSomething(i);

21
Q

In the following function declaration, the variable size is known as a ________.

int myFunction ( int size);

A

formal parameter

22
Q

Constant variables that might be used in different functions should be

23
Q

Write the code to convert the value in an integer variable named count to a double

A

static_cast(count)

24
Q

The absolute value function abs is located in the ________ library

25
The ________ of a variable is where that variable can be used.
scope
26
Variables that are declared inside a function are said to be ________ to that function.
local
27
Converting from one type to another is called \_\_\_\_\_\_\_\_.
type casting
28
When you want to use a function in your program, you would make a function \_\_\_\_\_\_\_\_.
call or invocation
29
Algorithms are typically described in \_\_\_\_\_\_\_\_.
pseudo code
30
The ________ describes how the function will work.
body
31
Function naming rules follow variable naming rules.
True
32
Every include directive must be followed by using namespace std;
False
33
The parameter names are mandatory in the function header.
False
34
Functions may have multiple return statements.
True
35
A function may return more than one item.
False
36
Variables that are declared outside of any function body or parameter list are considered global.
True
37
The parameters listed in the function declaration are considered global variables.
False