Chapters 6 and 7-- C++ Computer Programming

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

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

55

Subscript numbering in C++

begins with zero

A _____ argument is passed to a parameter when the actual argument is left out of the function call.

default

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

default

A function ____ contains the statements that make up a function.

definition

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

document

Look at the following function prototype: int myFunction(double); What is the data type of the function's parameter variable?

double

A _____ variable is declared outside all functions.

global

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

header

Arrays may be _____ at the time they are _____.

initialized; called

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

int

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

int array[10];

The name of an array stores the _____ of the first array element.

memory address

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

prototype

This vector function returns the number of elements in a vector.

size

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

subscript

This vector function removes an item from a vector.

pop_back

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

4

EXIT_FAILURE and _____ are named constants that may be used to indicate success or failure when the exit() function is called.

EXIT_SUCCESS

A collection of statements that perform a specific task.

a function

To assign the contents of one array to another, you must use _____.

a loop

A(n) _____ is information that is passed to a function, and a(n) _____ is information that is received by a function.

argument; parameter

Unlike regular variables, these can hold multiple values.

arrays

A function is executed when it is...

called

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

calls

An array's size declarator must be a _____ with a value greater than _____.

constant interger; zero

In a function header, you must furnish:

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

The individual values contained in an array are known as _____.

elements

This vector function returns true if the vector has no elements.

empty

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

exit( )

An array can easily be stepped through by using a _____.

for loop

This is a statement that causes a function to execute.

function call

An array with no elements is _____.

illegal in C++

The statement: int grades [ ] = {100, 90, 99, 80}; shows an example of:

implicit array sizing

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

initialization list

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

legal in C++

This type of variable is defined inside a function and is not accessible outside the function.

local

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

name

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

null terminator

A function can have zero to many parameters, and it can return this many values.

only one

If a function is called more than once in a program, the values stored in the function's local variables do not _____ between function calls.

persist

This vector function is used to insert an item into a vector.

push_back

The range-based for loop, in C++ 11, is designed to work with a built-in variable known as the _____.

range variable

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

reference

This statement causes a function to end.

return

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

scores [2]

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

static

The value in a _____ variable persists between functions.

static local

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

string names[5];

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

stub

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

subscript

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

the same data type

_____ functions may have the same name, as long as their parameter lists are different.

two or more

Which statement correctly uses C++11 to initialize a vector of ints named n with the values 10 and 20?

vector<int> n {10, 20};

Which statement correctly defines a vector object for holding integers?

vector<int> v;


Set pelajaran terkait

Basis of Human Movement Final Exam

View Set

Chapter 12: The Effective Change Manager: What Does It Take?

View Set

Bacteriostatic Inhibitors of Protein Synthesis 2

View Set

ch. 16 financial management and planning

View Set

5/4 Class 2: Abraham, Lot, Issac

View Set