CSCE 206 - Exam 3 - Practice 2

False
T/F Assume array1 and array 2 are the names of arrays. To assign the contents of array2 to array1, you would use the following statement.

array1 = array2;

False
T/F When you pass an array as an argument to a function, the function will create a local copy of the array
We will write a custom essay sample on
CSCE 206 – Exam 3 – Practice 2
or any similar topic only for you
Order now
False
T/F If you attempt to store data past an array’s boundaries, it is guaranteed that the compiler will issue an error
True
T/F An individual array element can be processed like any other type of C++ variable
True
T/F if an array is partially initialized, the uninitialized elements will be set to zero
False
T/F The bubble sort is an easy way to arrange data into ascending order, but it cannot arrange data into descending order
True
T/F The number of comparisons made by a binary search is expressed in powers of two
False
T/F Before you can perform a selection sort, the data must be stored in ascending order
False
T/F Using a binary search, you are more likely to find an item than if you use a linear search
False
T/F With pointer variables you can access, but you cannot modify, data in other variables.
True
T/F It is legal to subtract a pointer variable from another pointer variable
True
T/F 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
True
T/F A pointer can be used as a function parameter, giving the function access to the original argument,
False
T/F The ampersand (&) is used to dereference a pointer variable in C++
True
T/F Assuming “myValues” is an array of “int” values, and “index” is an “int” variable, both of the following statements do the same thing.

cout<< myValue [index] << endl; cout<< *(myValues + index) << endl;

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

A) int array[0];
B) float $payments[10];
C) void numbers[5];
D) int array[10];
E) None of these

D
The statement:
int grades[ ]= {100,90,99,80};

shows an example of:
A) default arguments
B) an illegal array declaration
C) an illegal array initialization
D) implicit array sizing
E) None of these

A
If you leave out the size declarator in array definition

A) you must finish an initialization list
B) you are not required to initialize the array elements
C) all array elements default to zero values
D) your array will contain no elements
E) will give an error

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

A) all dimensions
B) all but the first dimension
C) the size declarator of the first dimension
D) all elements values
E) None of these

C
An array’s size declarator must be a ____ with a value greater than ____.

A) number, one
B) number, zero
C) constant integer expression, zero
D) variable, -1
E) None of these.

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

A) the assignment operator with the array names
B) the quality operator with the array names
C) a loop to assign the elements of one array to the other array
D) Any of these
E) None of these

C
a two-dimension array of characters can contain _____.

A) strings of the same length
B) strings of different lengths
C) uninitialized elements
D) All of these
E) None of these

B
It is _______ to pass an argument to a function that is an individual array element, such as numbers [3]

A) illegal in C++
B) legal in C++
C) not recommended by the ANSI committee
D) not good programming practice
E) None of these

C
What will the following code display?

int numbers [] = {99,87,66,55,101};
for (int I =1 ; I<4; I++) cout << numbers [I] << endl; A) 99 87 66 55 101 B) 87 66 55 101 C) 87 66 55 D) 99 87 66 E) nothing. This code has an error

B
What will the following code display?

int number [4] = {99,87};
cost << numbers [3] << endl; A) 87 B) 0 C) garbage D) Null character E) This code will not compile

D
Which statement correctly defines a vector object for holding integers?

A) vector v;
B) int vector v;
C) int v;
D) vector v;
E) vector;

D
What does the following statement do?

vector v(10,2);

A) It creates a vector object and initializes all the first two elements with the values 10 and 2.
B) It creates a vector object with a starting size of 2 and the first element initialized with the value 10
C) It creates a vector object with a starting size of 10 and the first element initialized with the value 2
D) It creates a vector object with a starting size of 10 and all elements are initialized with the value 2
E) None of these

B
What does the following statement do?

vector v(10);

A) It creates a vector object and initializes all of its elements to the value 10.
B) It creates a vector object with a starting size of 10
C) It creates a vector object and initializes the first element with the value 10.
D) It creates a vector object that can store only values of 10 or less.
E) E) None of these

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

A) insert_item
B) add_item
C) store
D) push_back
E) at

D
This vector function removes an item from a vector

A) remove_item
B) delete_item
C) erase
D) pop_back
E) pop

C
The advantage of linear search is its _____
A) complexity
B) efficiency
C) simplicity
D) speed
E) None of these
D
A binary search begins with the _______ element of an array

A) first
B) last
C) largest
D) middle
E) None of these

C
A(n) _______ search is more efficient than _____ search

A) character, string
B) integer, double
C) binary, linear
D) linear, binary
E) None of these

C
The _____ sort usually performs fewer exchanges than the _____ sort.

A) bubble, linear
B) binary, linear
C) selection, bubble
D) ANSI, ASCII
E) None of these

E
Regardless of the algorithm being used, a search through an array is *always* performed

A) from lowest to highest element
B) from highest to lowest element
C) beginning with the middle element
D) using a binary search
E) None of these

E
The contents of the following array after two passes of Bubble Sort (ascending) are:

11, 8, 3, 20, 24, 5

A) 8, 3, 11, 20, 5, 24
B) 8, 11, 3, 5, 20, 24
C) 3, 5, 11, 20, 24, 8
D) 2, 5, 8, 11, 20, 24
E) 3, 8, 11, 5, 20, 24

C
With pointer variable, you can ______ manipulate data stored in other variables.

A) never
B) seldom
C) indirectly
D) all of these
E) None of these

A
_________ can be used as pointers

A) array names
B) Numeric constants
C) Function marks
D) all of these
E) None of these

C
The contents of pointer variables may be changed with mathematical statements that perform ______

A) all mathematical operations that are legal in C++
B) multiplication and division
C) addition and subtraction
D) B and C
E) None of these

C
When the less than ( < ) operator is used between two pointer variable, the expression is testing whether _____ A) the value pointed to by the first is less than the value pointed to by the second B) the value pointed to by the first is greater than the value pointed to by the second C) the address of the first variable comes before the address of the second variable in the computer's memory D) the first variable was declared before the second variable E) None of these
C
Look at the following statement:

sum += * (array++);

this statement ______
A)is illegal in C++
B) will always result in a compiler error
C) assigns the dereferenced pointer’s value, then increments the pointer’s address
D) increments the dereferenced pointer’s value by one, then assigns that value
E) None of these

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

A) still points to a valid object after the function ends
B) has not been assigned an address
C) was received as a parameter by the function
D) has not previously been returned by another function
E) None of these

D
The following statement:
cin >> *num3;

A) stores the keyboard input into the variable num3
B) stores the keyboard input into the pointer called num3
C) is illegal in C++
D) stores the keyboard input into the variable pointed to by num3
E) None of these

B
Dynamic memory allocation occurs ____

A) when a new variable is created by the compiler
B) when a new variable is created at runtime
C) when a pointer fails to dereference the right variable
D) when a pointer is assigned an incorrect address
E) None of these

C
The following statement:
int *ptr = new int;

A) results in a compiler error
B) assigns an integer less than 32767 to the variable named ptr
C) assigns an address to the variable named ptr
D) creates a are pointer named int
E) None of these

C
If a variable uses more than one byte of memory, for pointer purposes its address is ______

A) the address of the last byte storage
B) the average of the dresses used to store the value
C) the address of the fist byte of storage
D) general delivery
E) None of these

B
What will the following code output?
int number = 22;
int *var = &number;
cout << *var << endl; A) the address of the number variable B) 22 C) an asterisk followed by 22 D) an asterisk followed by the address of the number variable E) second statement throws an error
D
What will the following code output?

int *numbers = new int[5];
for (int I = 0; I<= 4; I++) *(numbers+i) =I; cout<< numbers [2] << endl; A) Five memory addresses B) 0 C) 3 D) 2 E) 1

C
Look at the following code:

int numbers [ ] = {0,1,2,3,4};
int *ptr = numbers;
ptr++;

After this code executes, which of the following statements is true?
A) ptr will hold the address of numbers[0] B) ptr will hold the address of the 2nd byte within the element numbers[0] C) ptr will hold the address of numbers [1] D) 3rd statement will generate error
E) 2nd statement will generate error

A
What is the output of this program?

#include
using namespace std
int main()
{
char arr[20];
int I;
for (I = 0 ; I < 10 ; I++) *(arr + i) = 65 + I ; *(arr + i) = '' ; cout << arr; return (0); } A) ABCDEFGHIJ B) AAAAAAAA C) JJJJJJJ D) none of the mentioned E) none of these

×

Hi there, would you like to get such a paper? How about receiving a customized one? Check it out