Ch.4 Flashcards

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.

A

scope

17
Q

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

float x = 36.0;

x = sqrt(x)

A

6.0

18
Q

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

A

type cast

19
Q

What is the value returned by the following function?

int function( )

{

int value = 35;

return value + 5;

value += 10;

}

A

40

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);

A

0

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

A

global

23
Q

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

A

static_cast<double>(count)</double>

24
Q

The absolute value function abs is located in the ________ library

A

stdio.h>

25
Q

The ________ of a variable is where that variable can be used.

A

scope

26
Q

Variables that are declared inside a function are said to be ________ to that function.

A

local

27
Q

Converting from one type to another is called ________.

A

type casting

28
Q

When you want to use a function in your program, you would make a function ________.

A

call or invocation

29
Q

Algorithms are typically described in ________.

A

pseudo code

30
Q

The ________ describes how the function will work.

A

body

31
Q

Function naming rules follow variable naming rules.

A

True

32
Q

Every include directive must be followed by using namespace std;

A

False

33
Q

The parameter names are mandatory in the function header.

A

False

34
Q

Functions may have multiple return statements.

A

True

35
Q

A function may return more than one item.

A

False

36
Q

Variables that are declared outside of any function body or parameter list are considered global.

A

True

37
Q

The parameters listed in the function declaration are considered global variables.

A

False