CS Exam 3

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

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

False

True/False: A function's return data type must be the same as the function's parameter(s).

False

True/False: A local variable and a global variable may not have the same name within the same program.

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: Assume array1 and array2 are the names of arrays. To assign the contents of array2 to array1, you would use the following statement. array1 = array2

False

True/False: C++ limits the number of array dimensions to two.

False

True/False: If you attempt to store data past an array's boundaries, it is guaranteed that the compiler will issue an error.

False

True/False: In C++ 11, the range-based for loop is best used in situations where you need the element subscript for some purpose.

False

True/False: The statement: double money[25.00]; is a valid C++ array definition.

False

Given the following function definition: void calc (int... etc What is the output of the following code fragment that invokes calc?

1 6 3

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

only one

What does the following statement do? vector<int> v(10, 2);

It creates a vector object with a starting size of 10 and all elements are initialized with the value 2.

True/False: A parameter is a special-purpose variable that is declared inside the parentheses of a function definition.

True

True/False: A static variable that is defined within a function is initialized only once, the first time the function is called.

True

True/False: A vector object automatically expands in size to accommodate the items stored in it.

True

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

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: Global variables are initialized to zero by default.

True

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

True

True/False: In C++ 11, you cannot use a range-based for loop to modify the contents of an array unless you declare the range variable as a reference.

True

True/False: It is not considered good programming practice to declare all of your variables globally.

True

True/False: One reason for using functions is to break programs into manageable units, or modules

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.

True

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

True

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

True

A pointer variable may be initialized with ________.

a valid address in the computer's memory

When writing functions that accept multi-dimensional arrays as arguments, ________ must be explicitly stated in the parameter list.

all but the first dimension

Subscript numbering in C++________.

begins with zero

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

constant integer expression, zero

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

memory address

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

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

A two-dimensional array is like ________ put together.

several identical arrays

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

stub

How many elements does the following array have?

1000

[int myFunction( doub, doub, doub);] How many parameter variables does this function have?

3

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

4

What is the output of the following program?

4 & 2 & 2 & 7 2 0 0 2 0

Which of the following statements about global variables is true?

A global variable can have the same name as a variable that is declared locally within a function.

A two-dimensional array of characters can contain ________.

All of these

In a function header, you must furnish:

All of these { data type(s) of the parameters, data type of the return value, the name of function, name of parameter variables }

What will the following code do? const int SIZE = 5; double x[SIZE]; for(int i = 2; i <= SIZE; i++) { x[i] = 0.0; }

An error will occur when the code runs

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

Default

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

EXIT_SUCCESS

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

False

True/False: Local variables are initialized to zero by default.

False

True/False: When a function is called, flow of control moves to the function's prototype

False

True/False: You must furnish an argument with a function call.

False

What does the following statement do? vector<int> v(10);

It creates a vector object with a starting size of 10.

Break :)

Making the study set even for Micheal, (break)

True/False: It is possible for a function to have some parameters with default arguments and some without.

True

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

Two or more

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

a loop to assign the elements of one array to the other array

A pointer variable is designed to store ________.

a memory address

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

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

call

A function is executed when it is:

called

Which of the following is a valid call to the function?

computeValue(10);

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

definition

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

document

[int myFunction( double);] What is the data type of the function's parameter variable?

double

The individual values contained in 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 collection of statements that performs a specific task.

function

This is a statement that causes a function to execute.

function call

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

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

Arrays may be ________ at the time they are ________.

initialized, declared

[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]; / int scores [10];

It is ________ to pass an argument to a function that contains an individual array element, such as 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

This vector function removes an item from a vector.

pop_back

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

prototype

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

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

rows, columns

Given the following declaration, where is the value 77 stored in the scores array?

scores[2]

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

size

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

static

The value in a ________ variable persists between function calls.

static local

A function may return a pointer, but the programmer must ensure that the pointer ________.

still points to a valid object after the function ends

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

string names[5];

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

subscript

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

subscript

An element of a two-dimensional array is referred to by ________ followed by ________.

the row subscript of the element, the column subscript of the element

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

the same data type

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;

If you leave out the size declarator in an array definition:

you must furnish an initialization list


Kaugnay na mga set ng pag-aaral

Kozier and Erb's chapter 1 study questions

View Set

Experiment 7: Dehydration of Cyclohexanol

View Set