Final Exam

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

call

Functions are ideal for use in menu-driven programs. When a user selects a menu item, the program can ________ the appropriate function.

scores [2]

Given the following declaration, where is 77 stored in the scores array? int scores[ ]={83, 62, 77, 97};

header

If a function does not have a prototype, default arguments may be specified in the function ________.

True

If an array is partially initialized, the uninitialized elements will be set to zero.

false

If you attempt to store data past an array's boundaries, it is guaranteed that the compiler will issue an error. (T/F)

null statement

If you place a semicolon after the test expression in a while loop, it is assumed to be a(n):

for

If you want a user to enter exactly 20 values, which loop would be the best to use?

initialization

In a for statement, this expression is executed only once.

True

One reason for using functions is to break programs into manageable units, or modules.

post-test

The do-while loop is considered a(n) ________ loop.

at least once

The statements in the body of a while loop may never be executed, whereas the statements in the body of a do-while loop will be executed:

fstream

To allow file access in a program, you must #include this header file

name

To pass an array as an argument to a function, pass the ________ of the array.

ifstream

To read data from a file, you define an object of this data type.

4

What is the last legal subscript that can be used with the following array? int values[5];

55

What will the following code display? int numbers[ ] = {99, 87, 66, 55, 101 }; cout << numbers[3] << endl;

False

When a function is called, flow of control moves to the function's prototype.

False

You must furnish an argument with a function call.

a nested loop

A loop that is inside another loop is called:

true

A while loop's body can contain multiple statements, as long as they are enclosed in braces. (T/F)

initialization list

A(n) ________ can be used to specify the starting values of an array.

linear

A(n) ________ search uses a loop to sequentially step through an array.

True

An individual array element can be processed like any other type of C++ variable.

buffer

A file _________ is a small holding section of memory that file-bound information is first written to.

update

A for statement contains three expressions: initialization, test, and:

definition

A function ________ contains the statements that make up the function.

prototype

A function __________ eliminates the need to place a function definition before all calls to the function.

False

A local variable and a global variable may not have the same name within the same program.

one

A two-dimensional array can have elements of _________ data type(s).

default

A(n) _________ argument is passed to a parameter when the actual argument is left out of the function call.

for loop

An array can easily be stepped through by using a:

False

Assume array1 and array2 are the names of arrays. To assign the contents of array2 to array1, you would use the following statement.

outFile << number;

Assuming outFile is a file stream object and number is a variable, which statement writes the contents of number to the file associated with outFile?

from lowest to highest value

Data that is sorted in ascending order is ordered

True

Each individual element of an array can be accessed by the array name and an element number, called a subscript.

call

Functions are ideal for use in menu-driven programs. When a user selects a menu item, the program can ________ the appropriate function.

elements

The individual values contained in array are known as

False

The scope of a variable declared in a for loop's initialization expression always extends beyond the body of the loop.

static local

The value in a(n) _______ variable persists between function calls.

True

You may use the exit( ) function to terminate a program, regardless of which control mechanism is executing.

the same data type

An array can store a group of values, but the values must be

the same data type

An array can store a group of values, but the values must be:

string names[5];

An array of string objects that will hold 5 names would be declared using which statement?

illegal in C++

An array with no elements is

constant integer expression, zero

An array's size declarator must be a(n)_________ with a value greater than _________.

False

Local variables are initialized to zero by default.

int

Look at the following function prototype. int myFunction(double); What is the data type of the funtion's return value

E) none of these

Regardless of the algorithm being used, a search through an array is always performed A) from lowest to highest element B) from highest to lowest element C) beginning with the middle element D) using a binary search E) None of these

static local

The value in a(n) ________ variable persists between function calls.

static

The value in this type of local variable persists between function calls.

a statement or block that is repeated as long as the expression is true

The while loop has two important parts: an expression that is tested for a true or false value, and:

default

These types of arguments are passed to parameters automatically if no argument is provided in the function call.

function

This is a collection of statements that performs a specific task.

stub

This is a dummy function that is called instead of the actual function it represents.

while

This is a pre-test loop that is ideal in situations where you do not want the loop to iterate if the condition is false from the beginning.

sentinel

This is a special value that marks the end of a list of values.

counter

This is a variable that is regularly incremented or decremented each time a loop iterates.

for

This loop is a good choice when you know how many times you want the loop to iterate in advance of entering the loop.

stream insertion operator

This may be used to write information to a file.

increment

This means to increase a value by one.

prefix increment

This operator increments the value of its operand, then uses the value in context.

Subscript

To access an array element, use the array name and the element's:

ofstream

To write data to a file, you define an object of this data type

false

True/False: Although two-dimensional arrays are a novel idea, there is no known way to pass one to a function.

false

True/False: An array initialization list must be placed on one single line.

true

True/False: Each individual element of an array can be accessed by the array name and an element number, called a subscript.

true

True/False: The amount of memory used by an array depends upon the array's data type and the number of elements in the array.

false

True/False: The bubble sort is an easy way to arrange data into ascending order, but it cannot arrange data into descending order.

arrays

Unlike regular variables, these can hold multiple values.

True

When you pass an array as an argument to a function, the function can modify the contents of the array.

variable

You may define a __________ in the initialization expression of a for loop.

False

You may nest while and do-while loops, but you may not nest for loops.

False

You may not use the break and continue statements within the same set of nested loops.

global

A ________ variable is declared outside all functions.

closes a file

Assuming dataFile is a file stream object, the statement dataFile.close();

post-test

The do-while loop is considered a(n) _________ loop

pre-test

The while loop is this type of loop

int array[10]

Which of the following is a valid C++ array definition?

global

A ___________ variable is declared outside all functions.

opened

A file must be ________ before data can be written to or read from it.

rows, columns

A two-dimensional array can be viewed as ________ and ________.

initialized, declared

Arrays may be ________ at the time they are ________.

subscript

By using the same ________ you can build relationships between data stored in two or more arrays

data type(s) of the parameters data type of the return value the name of function names of parameter variables

In a function header, you must furnish:

legal in C++

It is ________ to pass an argument to a function that contains an individual array element, such as numbers[3].

document

It is a good programming practice to ____________ your functions by writing comments that describe what they do.

True

It is not considered good programming practice to declare all of your variables globally.

true

It is not considered good programming practice to declare all of your variables globally. (T/F)

infinite loop

Something within a while loop must eventually cause the condition to become false, or a(n) __________ results.

begins with 0

Subscript numbering in C++

null terminator

The ________ is automatically appended to a character array when it is initialized with a string constant.

null terminator

The ______________ is automatically appended to a character array when it is initialized with a string constant.

simplicity

The advantage of a linear search is its ____________.

post-test

The do-while loop is a __________ loop that is ideal in situations where you always want the loop to iterate at least once.

exit()

This function causes a program to terminate, regardless of which function or control mechanism is executing

break

This statement causes a loop to terminate early.

continue

This statement may be used to stop a loop's current iteration and begin the next one

subscript

To access an array element, use the array name and the element's

prefix

When the increment operator precedes its operand, as in ++num1, the expression is in this mode.

reference

When used as parameters, these types of variables allow a function to access the parameter's original argument.


Ensembles d'études connexes

MATERIAL MANAGNMENT EXAM 3 CH 9-13 terms

View Set

Solving Absolute Value Equations

View Set

Chapter 2: The Chemical Context of Life

View Set