C++ MidTerm

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

search

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

binary, linear

A _______ search is more efficient than a ________ search.

middle

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

False

A function cannot modify the members of a structure.

strstr

A library function that can find one C-string inside another is

strcat

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

selection, bubble

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

\0

The escape sequence that represents the null terminator is

True

The expression s -> m; indicates that s is a structure pointer and m is a structure member.

descending order

When an array is sorted from highest to lowest, it is said to be in

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

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

the linear search

The __________ is adequate for searching through small arrays.

simplicity

The advantage of a linear search is its

two addresses

The arguments of the strcpy function are

False

The bubble sort is an easy way to arrange data in ascending order but it cannot arrange data in descending order.

True

The expression *s -> p; indicates that s is a structure pointer and p, which is also a pointer, is a member of the structure pointed to by s.

both an alphabetic character and a symbol such as $ or &

The expression being tested by the statement shown below will evaluate to true if var1 is ________. if (!isdigit(var1))

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

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

stores the keyboard input into the variable pointed by num3

The following statement __________. cin >> *num3;

assigns an address to the variable ptr

The following statement __________. int *ptr = new int;

atol

The function that accepts a C-string as an argument and converts the string to a long integer is

strlen

The function that accepts a pointer to a C-string as an argument and returns the length of the C-string, not including the null terminator is

True

The number of comparisons made by a binary search is expressed in powers of two.

lowercase z

What is the output of the following statement? cout << tolower(toupper('Z')) << endl;

False

You cannot directly assign an enumerator to an int variable.

- function parameter - structure member -function return type

You may use a pointer to a structure as a

True

You may use the <, >, <+, >=, ++, and !+ relational operators to compare string objects.

int temp = num2; num2 = num1; num1 = temp;

Assume you have two integer variables, num1 and num2. Which of the following is the correct way to swap the values to these two variables?

False

It is possible to output the contents of all members of a structure variable using a cout << statement followed by the name of the structure variable.

var1 stores the ASCII value for lowercase 'a'

What is the result after the following statement executes? char var1 = tolower('A');

1000

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

the address of number

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

22

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

by reference

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

- declare the pointer value in the function call - dereference the pointer value in the function prototype - use the #include statement - not dereference the pointer in the function's body

When you pass a pointer as an argument to a function, you must not

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

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

employee [2]. hourlyWage = 75.00

Which of the following assigns a value to the hourlyWage member of employee[2]?

char str[50];

Which of the following defines an array of C-strings that will hold 49 characters and the null terminator?

abstraction

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

This statement assigns the dereferenced pointer's value, then increments the pointer's address.

Which of the following is TRUE about this statement? sum += *array++;

delete [ ] array;

Which of the following statements deletes memory that has been dynamically allocated for an array?

cout << &numb;

Which of the following statements displays the address of the variable numb?

int ptr = &num1; int ptr = int *num1; float num1 = &ptr2; All of these are invalid

Which of the following statements is NOT valid C++ code?

the dot operator

Which of the following will allow you to access structure members?

ispunct

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

False

With pointer variables you can access but not modify data in other variables.

Algorithms used to arrange random data in some order are _________ algorithms

sorting

True

On average, an item is just as likely to be found near the beginning of an array as near the end.

ptr will hold the address of numbers [1]

After the code shown executes, which of the following statements is TRUE?

1

After the following statement executes, what value will the MAPLE enumerator be stored as, in memory? enum Tree {OAK, MAPLE, PINE};

False

Before you can perform a bubble sort, the data must be stored in descending order

when a new variable is created at runtime

Dynamic memory allocation occurs

the -> operator

To dereference a structure pointer, the appropriate operator is

isspace

To determine whether a character entered is whitespace, use the __________ function.

smart pointer

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.

isdigit

To test whether a character is a numeric digit character, use the ____________ function.

Declares a pointer variable named num2

What does the following statment do? double *num2?;

15

With binary search algorithm, a maximum of ________ comparisons will be made on an array of 25,000 elements

False

A linear search can only be implementer with integer values.

True

A selection sort and a binary search can be applied to STL vectors as well as arrays.

True

A struct can contain members with varying data types.

the address of a structure variable

A structure pointer contains

False

A test using the isupper function will return false if the argument is an uppercase character

linear

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

sorting

Algorithms used to arrange random data in some order are _________ algorithms

True

An array name is a pointer constant because the address stored in it cannot be changed at runtime.

takes a Circle structure as a parameter, does something, and returns a Circle structure

If Circle is a structure tag, then the following statement can be the header line for a function that ___________. Circle doSomething( Circle c2)

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

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

output the dereferenced value pointed to by p

If a is a structure variable and p, a pointer, is a member of the structure, what will the following statement do? cout << *a.p;

True

If an upper character is passed as an argument to the toupper function, the result will be an uppercase character.

True

If you are using the bubble sort algorithm to sort an array in descending order, the smaller values move toward the end.

True

In C++ you can use smart pointers to dynamically allocate memory and not worry about deleting the memory when you are finished using it.

the first character of mystring

In C++11, assuming mychar is a char variable and mystring is a string, what is the value of mychar after the following statement executes? mychar = my.string.front( );

strongly typed enum

In C++11, you can use a new type of enum known as a(n) _______ (also known as an enum class) to have multiple enumerators with the same name, within the same scope.

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

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

True

By being able to pass arrays as arguments, you can write your own functions for processing C-strings.

True

C++ does not perform array bounds checking, making it possible for you to assign a pointer the address of an element out of the boundaries of an array.

abstract data types (ADTs)

Data types that are created by the programmer are known as

5

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]"

20,000

Using a linear search to find a value that is stored in the last element of an array that contains 20,000 elements, _________ elements must be compared.


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

Chapter 4: Secure Wireless Networking

View Set

Ten Top Tips on Queen Anne (1702-1714)

View Set

ENGINEERING STUDY GUIDE FOR INTERIM

View Set