COP 3014 Exam #3

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

Given the string shown below, if the delimiter is a space, how many tokens are in the string?"Tony's email address is [email protected]"

5

If Circle is a structure, what does the following statement do?Circle *pcirc = nullptr;

It declares a structure pointer called pcirc initialized with a null pointer.

Given the following structure declaration, Employee is struct Employee { string name; int idNum; };

a tag

A pointer variable may be initialized with

a valid address in the computer's memory

Data types that are created by the programmer are known as

abstract data types (ADTs)

Which of the following describes only the general characteristics of an object?

abstraction

Which of the following converts the string "10" to the integer value 10?

atoi("10");

Use the delete operator only on pointers that were

created with the new operator

Before a structure can be used it must be

declared

The C-string company[12] can hold

eleven characters and the null terminator

Which of the following will return true if the argument is a printable character other than a digit, letter, or space?

ispunct

A function ________ return a structure.

may

A binary search begins with the ________ element of an array.

middle

In the following statement, what does int mean? int *ptr = nullptr;

ptr is a pointer variable and will store the address of an integer variable.

After the code shown executes, which of the following statements is TRUE? int numbers[] = {0, 1, 2, 3, 4}; int *ptr = numbers; ptr++;

ptr will hold the address of numbers[1]

A ________ algorithm is a method of locating a specific item of information in a larger collection of data.

search

The following is the pseudocode for which type of algorithm? For start = each array subscript, from the first to the next-to-last minIndex = start minValue = array[start] For index = start + 1 To size - 1 If array[index] < minValue minValue = array[index] minIndex = index End If End For swap array[minIndex] with array[start] End For

selection sort

The ________ function concatenates the contents of one C-string with another C-string.

strcat

The function that accepts pointers to two C-strings and an integer argument that indicates how many characters to copy from the second string to the first is

strncpy

The ________ and ________ operators can be used to increment or decrement a pointer variable.

++, --

What is the value stored in num after the following statement executes?num = atoi("1000");

1000

What will the following code output? int number = 22; int *var = &number; cout << *var << endl;

22

The following function should swap the values contained in two integer variables, num1 and num2. What, if anything, is wrong with this function? void swap (int num1, int num2) { int temp = num2; num2 = num1; num1 = temp; }

The swap function must use reference parameters.

A ________ search is more efficient than a ________ search.

binary, linear

The following is the pseudocode for which type of algorithm? For maxElement = each subscript in the array, from the last to the first For index = 0 To maxElement - 1 If array[index] > array[index + 1] swap array[index] with array[index + 1] End If End For End For

bubble sort

When a structure is passed ________ to a function, its members are NOT copied.

by reference

Which of the following statements appropriately defines a C-string that stores names of up to 25 characters?

char name[26];

You may use a pointer to a structure as a

function parameter. structure member. function return type. All of these.

To determine whether a character entered is a letter of the alphabet, use the ________ function.

isalpha

The ________ sort usually performs fewer exchanges than the ________ sort.

selection, bubble

Which of the following is required after the closing brace of the structure definition?

semicolon

To help prevent memory leaks from occurring in C++11, a ________ automatically deletes a chunk of dynamically allocated memory when the memory is no longer being used.

smart pointer

Algorithms used to arrange random data in some order are ________ algorithms.

sort

Array elements must ________ before a binary search can be performed.

sorted

When you work with a dereferenced pointer, you are actually working with

the actual value of the variable whose address is stored in the pointer variable

When the less than operator (<) is used between two pointer values, the expression is testing whether

the address of the first variable comes before the address of the second variable in the computer's memory

The ________ is adequate for searching through small arrays.

the linear search

Assuming ptr is a pointer variable, what will the following statement output? cout << *ptr;

the value stored in the variable whose address is contained in ptr

The ________ function will change a character argument from lowercase to uppercase.

toupper

The following statement ________.bookList[2].publisher[3] = 't';

will store the character 't' in the fourth element of the publisher member of bookList[2]


Kaugnay na mga set ng pag-aaral

Foundations Test 2 PrepU questions

View Set

Genetics(H): Chapter 15 Practice Test(Relevant Questions)

View Set

Биохимия крови норма🤙

View Set

World's Largest Countries by Population

View Set

The Art of Public Speaking (Lucas) Chapter 7

View Set

CHAPTER 11: APPENDICULAR STRUCTURE

View Set