Exam 2 Review

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Reference variables are defined like regular variables, except there is a(n) _________ in front of the name.

&

What operator do you use to dereference a structure pointer?

->

Given the following function: void calc (int a, int&b) { int c; c = a + 2; a = a * 3; b = c + a; } What would be the output of: int x = 1, y = 2, z = 3; calc(x,y); cout << x << " " << y << " " << z << endl;

1 6 3

How many characters can the C-String char company[12] hold?

11

A(n) _________ is required after the closing brace of a structure declaration.

;

A structure variable may not be a member of another structure.

False

All static local variables are initialized to -1 by default.

False

All the members of a union may be used simultaneously.

False

An array's size declarator can be either a literal, a named constant, or a variable.

False

An entire structure may not be passed to a function as an argument.

False

Arrays cannot be initialized when they are defined. A loop or other means must be used.

False

If data are sorted in descending order, it means they are ordered from lowest value to highest value.

False

If you leave an element uninitialized, you do not have to leave all the ones that follow it uninitialized.

False

The & symbol is called the indirection operator.

False

The * operator is used to get the address of a variable.

False

The contents of a structure variable can be displayed by passing the structure variable to the cout object.

False

The exit function can only be called from main.

False

The maximum number of comparisons performed by the linear search on an array of N elements is N/2 (assuming the search values are consistently found).

False

The strlen function returns the size of the array containing a string.

False

The uninitialized elements of a string array will automatically be set to the value " 0".

False

The first size declarator (in the declaration of a two-dimensional array) represents the number of columns. The second size definition represents the number of rows.

False

There is no difference between "847" and 847.

False

When a function terminates, it always branches back to main, regardless of where it was called from.

False

When an array name is used without brackets and a subscript, it is seen as the value of the first element in the array.

False

You can change the address that an array name points to.

False

You can use the [ ] operator to insert a value into a vector that has no elements.

False

You may not define pointers to unions.

False

A structure declaration does not define a variable.

True

C++ allows you to create arrays with three or more dimensions.

True

C++ allows you to partially initialize an array.

True

Each byte of memory is assigned a unique address.

True

Function prototypes are terminated with a semicolon.

True

Functions should be given names that reflect their purpose.

True

If an anonymous union is defined globally (outside all functions), it must be declared static.

True

If data are sorted in ascending order, it means they are ordered from lowest value to highest value.

True

If toupper's argument is already uppercase, it is returned as is, with no changes.

True

In a function prototype, the names of the parameter variables may be left out.

True

In a structure variable's initialization list, you do not have to provide initializers for all the members.

True

Overuse of global variables can lead to problems.

True

Pointers may be compared using the relational operators.

True

String-handling functions accept as arguments pointers to strings (array names or pointer variables), or literal strings.

True

Subscript numbers may be stored in variables.

True

The address 0 is generally considered unusable.

True

The average number of comparisons performed by the linear search on an array of N elements is N/2 (assuming the search values are consistently found).

True

The individual elements of an array are accessed and indexed by unique numbers.

True

The new operator dynamically allocates memory.

True

The scope of a parameter is limited to the function which uses it.

True

The strcpy function will overwrite the contents of its first string argument.

True

The subscript of the last element in a single-dimensional array is one less than the total number of elements in the array.

True

To use a vector, you must include the vector header file.

True

When a function returns a structure, it is always necessary for the function to have a local structure variable to hold the member values that are to be returned.

True

When a function with default arguments is called and an argument is left out, all arguments that come after it must be left out as well.

True

When defining a parameter variable to hold a single-dimensional array argument, you do not have to include the size declarator.

True

When the indirection operator is used with a pointer variable, you are actually working with the value the pointer is pointing to.

True

When you add a value to a pointer, you are actually adding that number times the size of the data type referenced by the pointer.

True

What is the escape sequence for the null terminator?

\0

What are data types that the programmer creates known as?

abstract data types

The __________ operator can be used to determine a variable's address.

address ampersand

Any time the name of an array is used without brackets and a subscript, it is seen as _________.

address memory address

What does the name of the array store?

address of first element

If an array is sorted in _________ order, the values are stored from lowest to highest.

ascending

What is the name of the following operators: a) * b) &

asterisks ampersand

The _________ search algorithm repeatedly divides the portion of an array being searched in half.

binary

The _________ search algorithm requires that the array's contents be sorted.

binary

C++ has no array _________ checking, which means you can inadvertently store data past the end of an array.

bounds

To completely clear the contents of a vector, use the ___________ member function.

clear

When a two-dimensional array is passed to a function the _________ size must be specified.

column

The size declarator must be a(n) ________ with a value greater than _______.

constant integer expression zero

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

creates a vector with intial size 10 and each element initialized to 2

The variables declared inside a structure declaration are called _________.

data members members

Before a structure variable can be created, the structure must be _________.

declared defined

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

default

Either a function's _____ or its ______ must precede all calls to the function.

definition prototype

When a program is finished with a chunk of dynamically allocated memory, it should free it with the __________ operator.

delete

If you dynamically allocate an array, arr, how would you delete it (write the code)?

delete [] array

If an array is sorted in _________ order, the values are stored from highest to lowest.

descending

The _________ operator allows you to access structure members.

dot

Creating variables while a program is running is called __________.

dynamic memory allocation

What are individual values in an array known as?

elements

The _________ function causes a program to terminate.

exit() exit

What must you do to "copy" one array into another?

for loop

The _________ is the part of a function definition that shows the function name, return type, and parameter list.

function header header

A(n) _________ eliminates the need to place a function definition before all calls to the function.

function prototype prototype

_________ variables are defined outside all functions and are accessible to any function within their scope.

global

The __________ operator can be used to work with the variable a pointer points to.

indirection

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

integer zero

The _________ function returns true if the character argument is a letter of the alphabet.

isalpha

The _________ function returns true if the character argument is a whitespace character.

isspace

The _________ search algorithm is adequate for small arrays but not large arrays.

linear

The _________ search algorithm steps sequentially through an array, comparing each item with the search value.

linear sequential

The value of a default argument must be a(n) _________.

literal constant

What is the scope of a variable declared inside of a function (and a function header)?

local

What is a pointer variable designed to store?

memory address of a variable

The __________ operator is used to dynamically allocate memory.

new

A pointer that contains the address 0 is called a(n) __________ pointer.

null

Under older compilers, if the new operator cannot allocate the amount of memory requested, it returns __________.

null

Special variables that hold copies of function arguments are called _________.

parameter variables parameters

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

prototype

What vector function adds an item to the vector?

push_back

What type of variable must a parameter be in order for the function to access the parameter's original argument (i.e. the actual argument, not a copy)?

reference

In a function header (not prototype) what must you furnish? [It is acceptable to make a sample header and label each part]

return type, function name, parameter type, parameter name

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

scores[2]

To determine the number of elements in a vector, use the _____________ member function.

size

What condition does the array have to be in before a binary search can be performed?

sorted

_________ local variables retain their value between function calls.

static

The _________ function concatenates two strings (c-strings).

strcat

The _________ function copies, at most, n number of characters from one string to another.

strcpy

The _________ function returns the length of a string (c-strings).

strlen

The _________ function returns the lowercase equivalent of its character argument.

tolower

To define a two-dimensional array, _________ size declarators are required.

two

To define a vector in your program, you must #include the ____________ header file.

vector

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

zero

Subscript numbering in C++ always starts at _________.

zero

Unless you explicitly initialize global variables, they are automatically initialized to _________.

zero


संबंधित स्टडी सेट्स

LFIT Quiz Questions (Chapters 1-7 All)

View Set

Chapter 1: The Science of Physics

View Set

Quiz 2 MIS 3770 System Analysis Methods

View Set