Comp Sci Review

¡Supera tus tareas y exámenes ahora con Quizwiz!

A file must be ________ before data can be written to or read from it. Select one: a. closed b. opened c. buffered d. initialized e. None of these

b. (opened)

To write data to a file, you define an object of this data type. Select one: a. outputFile b. fstream c. ifstream d. ofstream

d. (ofstream )

The range-based for loop, in C++ 11, is designed to work with a built-in variable known as the ________. Select one: a. counter variable b. i variable c. iterator d. range variable e. None of these

d. (range variable)

A two-dimensional array can have elements of ________ data type(s). Select one: a. one b. two c. four d. Any of these e. None of these

a (one)

To allow file access in a program, you must #include this header file. Select one: a. fstream b. cfile c. file d. fileaccess

a. (fstream)

To read data from a file, you define an object of this data type. Select one: a. ifstream b. fstream c. ofstream d. inputFile

a. (ifstream )

An array with no elements is ________. Select one: a. legal in C++ b. illegal in C++ c. automatically furnished one element, with a value of zero d. automatically furnished one value—the null terminator e. None of these

a. (legal in C++)

Assuming outFile is a file stream object and number is a variable, which statement writes the contents of number to the file associated with outFile? Select one: a. outFile << number; b. write(outFile, number); c. outFile >> number; d. number >> outFile;

a. (outFile << number;)

When writing functions that accept multi-dimensional arrays as arguments, ________ must be explicitly stated in the parameter list. Select one: a. all dimensions b. all but the first dimension c. the size declarator of the first dimension d. all element values e. None of these

b. (all but the first dimension)

This is a variable that is regularly incremented or decremented each time a loop iterates. Select one: a. constant b. counter c. control statement d. null terminator e. None of these

b. (counter)

The while loop contains an expression that is tested for a true or false value, and a statement or block that is repeated as long as the expression: Select one: a. is false b. is true c. does not evaluate to true or false d. evaluates to true or false e. None of these

b. (is true)

It is ________ to pass an argument to a function that contains an individual array element, such as numbers[3]. Select one: a. illegal in C++ b. legal in C++ c. not recommended by the ANSI committee d. not good programming practice e. None of these

b. (legal in C++)

Which statement correctly uses C++ 11 to initialize a vector of ints named n with the values 10 and 20? Select one: a. int vector n ({10}, {20}); b. vector<int> n { 10, 20 }; c. vector<int> n = {10, 20}; d. vector n<int>(10, 20);

b. (vector<int> n { 10, 20 };)

What will the following code display? int number= 6; int x=0; x=--number; cout <<x<< endl; Select one: a. 7 b. 6 c. 5 d. 0

c. (5)

What will the following code display? int number= 6; number++; cout <<number<< endl; Select one: a. 5 b. 6 c. 7 d. 0

c. (7)

A file ________ is a small holding section of memory that file-bound information is first written to. Select one: a. name b. number c. buffer d. segment e. None of these

c. (buffer)

Assuming dataFile is a file stream object, the statement: dataFile.close(); Select one: a. is illegal in C++ b. needs a filename argument to execute correctly c. closes a file d. is legal but risks losing valuable data e. None of these

c. (closes a file)

An array's size declarator must be a ________ with a value greater than ________. Select one: a. number, one b. number, zero c. constant integer expression, zero d. variable, -1 e. None of these

c. (constant integer expression, zero)

If you place a semicolon after the test expression in a while loop, it is assumed to be aNo: Select one: a. pre-test loop b. post-test loop c. null statement d. infinite loop e. None of these

c. (null statement)

What will the following code display? int numbers={99,87,66,55,101}; for (int i=1; i<4; i++) cout<<numbers[i]<<endl; Select one: a. 99 87 66 55 101 b. Nothing. This code has an error. c. 87 66 55 101 d. 87 66 55

d ( 87 66 55 )

Subscript numbering in C++________. Select one: a. can be set at runtime b. can begin with a programmer-defined value c. varies from program to program d. begins with zero e. None of these

d (begins with zero)

What will the following code display? int numbers[4]={99,87}; cout<<numbers[3]<<endl; Select one: a. This code will not compile b. garbage Incorrect c. 87 d. 0

d. (0)

What is the output of the following code segment? n=1; while (n<= 5) cout <<n<<' '; n++; Select one: a. 2 3 4 5 b. 1 2 3 4 5 c. 1 2 3 4 d. 1 1 1... and on forever e. 2 3 4 5 6

d. (1 1 1... and on forever)

What will the following code display? int x=0; for(int count=0; count<3; count++) x+=count; cout <<x<<endl; Select one: a. 6 b. 0 1 2 c. 0 d. 3

d. (3)

What does the following statement do? vector<int> v(10,2); Select one: a. It creates a vector object with a starting size of 2 and the first element initialized with the value 10. b. It creates a vector object and initializes all the first two elements with the values 10 and 2. 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.

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

This statement may be used to stop a loop's current iteration and begin the next one. Select one: a. break b. terminate c. re-iterate d. continue e. None of these

d. (continue)

Which of the following is a valid C++ array definition? Select one: a. int array[0]; b. float $payments[10]; c. void numbers[5]; d. int array[10]; e. None of these

d. (int array[10];)

This may be used to write information to a file. Select one: a. cout object b. pen object c. output object d. stream insertion operator e. None of these

d. (stream insertion operator)

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

f (False)

True/False: The increment and decrement operators can be used in mathematical expressions; however, they cannot be used in relational expressions. Select one: True False

f (False)


Conjuntos de estudio relacionados

Magento 2 Certified Developer(MCAD+MCPD)

View Set

Osgood-Schlatter Disease, Legg-Calve-Perthes disease, Osteosarcoma

View Set

Metamorphic Processes and products

View Set

Chapter 4: Formation of the Solar System (Textbook Notes)

View Set

Marketing Chapter 17 Test- 12/11/15

View Set

prep u 140 infection and inflammation

View Set