Lee's C++ Ch 1-9 Exam 1 lecture review
A function ________ contains the statements that make up the function. Question options: A) definition B) expression C) parameter list D) call E) prototype
A
A function may return a pointer, but the programmer must ensure that the pointer: Question options: A) still points to a valid object after the function ends B) has not been assigned an address C) has not previously been returned by another function D) was received as a parameter by the function E) None of these
A
A loop that is inside another loop is called: Question options: A) a nested loop B) an infinite loop C) a post-test loop D) a pre-test loop E) None of these
A
A pointer variable may be initialized with: Question options: A) any address in the computer's memory B) any non-zero integer value C) an address less than 0 D) A and C only E) None of these
A
A two-dimensional array can have elements of ________ data type(s). Question options: A) one B) four C) two D) Any of these E) None of these
A
A two-dimensional array is like ________ put together. Question options: A) several identical arrays B) an array and a function C) two functions D) two arrays of different types E) None of these
A
A(n) ________ search is more efficient than a(n) ________ search Question options: A) binary, linear B) character, string C) integer, double D) linear, binary E) None of these
A
An array with no elements is: Question options: A) illegal in C++ B) automatically furnished one value -- the null terminator C) legal in C++ D) automatically furnished one element, with a value of zero E) None of these
A
An element of a two-dimensional array is referred to by ________ followed by ________. Question options: A) the row subscript of the element, the column subscript of the element B) the array name, the column number of element C) a comma, a semicolon D) the row subscript of element, the array name E) None of these
A
Array elements must be ________ before a binary search can be performed. Question options: A) sorted B) set to zero C) summed D) positive numbers E) None of these
A
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? Question options: A) outFile << number; B) outFile >> number; C) write(outFile, number); D) number >> outFile;
A
Computer programs are also known as: Question options: A) software B) hardware C) silverware D) firmware E) None of these
A
During which stage does the central processing unit retrieve from main memory the next instruction in the sequence of program instructions? Question options: A) fetch B) portability stage C) execute D) decode
A
Dynamic memory allocation occurs: Question options: A) when a new variable is created at runtime B) when a pointer is assigned an incorrect address C) when a new variable is created by the compiler D) when a pointer fails to dereference the right variable E) None of these
A
Even when there is no power to the computer, data can be held in: Question options: A) secondary storage B) the algorithm C) the input device D) the output device E) None of these
A
Given that x = 2, y = 1, and z = 0, what will the following cout statement display? cout << "answer = " << (x || !y && z) << endl; Question options: A) answer = 1 B) answer = 2 C) answer = 0 D) None of these
A
Here is the header for a function named computeValue: void computeValue(int value) Which of the following is a valid call to the function? Question options: A) computeValue(10); B) void computeValue(int x); C) void computeValue(10); D) computeValue(10)
A
How many times will the following loop display "Hello"? for (int i = 1; i < 20; i++) cout << "Hello!" << endl; Question options: A) 19 B) 20 C) 21 D) an infinite number of times
A
How many times will the following loop display "Hello"? for (int i = 20; i > 0; i--) cout << "Hello!" << endl; Question options: A) 20 B) 21 C) 19 D) an infinite number of times
A
If a function is called more than once in a program, the values stored in the function's local variables do not ________ between function calls. Question options: A) persist B) execute C) change D) communicate E) None of these
A
If you leave out the size declarator in an array definition: Question options: A) you must furnish an initialization list B) your array will contain no elements C) all array elements default to zero values D) you are not required to initialize the array elements
A
In C++ the = operator indicates: Question options: A) assignment B) negation C) subtraction D) equality E) None of these
A
In a for statement, this expression is executed only once. Question options: A) initialization B) null C) validation D) test E) None of these
A
Internally, the CPU consists of two parts: Question options: A) the control unit and the arithmetic and logic unit B) the single-task device and the multi-task device C) the output device and the input device D) the software and the hardware E) None of these
A
Look at the following function prototype. int myFunction(double, double, double); How many parameter variables does this function have? Question options: A) 3 B) 2 C) 1 D) can't tell from the prototype
A
Look at the following program and answer the question that follows it. 1 // This program displays my gross wages. 2 // I worked 40 hours and I make $20.00 per hour. 3 # include <iostream> 4 using namespace std; 5 6 int main( ) 7 { 8 int hours; 9 double payRate, grossPay; 10 11 hours = 40; 12 payRate = 20.0; 13 grossPay = hours * payRate; 14 cout << "My gross pay is $" << grossPay << endl; 15 return 0; 16 } Which line(s) in this program cause output to be displayed on the screen? Question options: A) 14 B) 13 and 14 C) 13 D) 15 E) 8 and 9
A
Look at the following statement. int *ptr; In this statement, what does the word int mean? Question options: A) ptr is a pointer variable that will store the address of an integer variable. B) The variable named *ptr will store an asterisk and an integer value. C) The variable named *ptr will store an integer value. D) All of these E) None of these
A
Look at the following statement. while (x++ < 10) Which operator is used first? Question options: A) < B) ++ C) Neither. The expression is invalid.
A
Mistakes that cause a running program to produce incorrect results are called: Question options: A) logic errors B) compiler errors C) syntax errors D) linker errors E) None of these
A
Programmer-defined names of memory locations that may hold data are: Question options: A) variables B) syntax C) operands D) operators E) None of these.
A
The ________ and ________ operators can be used to increment or decrement a pointer variable. Question options: A) ++, -- B) modulus, division C) addition, subtraction D) All of these E) None of these
A
The ________ decodes an instruction and generates electrical signals. Question options: A) control unit B) main memory C) arithmetic and logic unit D) BIOS E) None of these
A
The ________ is adequate for searching through small arrays. Question options: A) linear search B) unary search C) bubble sort D) binary search E) None of these
A
The default section of a switch statement performs a similar task as the ________ portion of an if/else if statement. Question options: A) trailing else B) conditional C) break D) All of these E) None of these
A
The float data type is considered ________ precision, and the double data type is considered ________ precision. Question options: A) single, double B) short, long C) float, double D) integer, double E) None of these
A
The individual values contained in array are known as: Question options: A) elements B) constants C) parts D) numbers E) None of these
A
The statement int *ptr; has the same meaning as Question options: A) int* ptr; B) *int ptr; C) int ptr*; D) int ptr; E) None of these
A
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: Question options: A) is true B) is false C) does not evaluate to true or false D) evaluates to true or false E) None of these
A
The while loop has two important parts: an expression that is tested for a true or false value, and: Question options: A) a statement or block that is repeated as long as the expression is true B) a statement or block that is repeated once, if the expression is true C) a statement or block that is repeated only if the expression is false D) one line of code that is repeated once, if the expression is true
A
This function tells the cin object to skip one or more characters in the keyboard buffer. Question options: A) cin.ignore B) cin.skip C) cin.hop D) cin.jump E) None of these
A
This is a special value that marks the end of a list of values. Question options: A) sentinel B) loop C) constant D) variable E) None of these
A
This is a volatile type of memory, used for temporary storage. Question options: A) RAM B) a hard disk C) a floppy disk D) ALU E) None of these
A
This is used in a program to mark the beginning or ending of a statement, or separate items in a list. Question options: A) punctuation B) operators C) separators D) key words E) None of these
A
This is used to mark the end of a complete C++ programming statement. Question options: A) semicolon B) pound sign C) data type D) void E) None of these
A
This means to increase a value by one. Question options: A) increment B) modulus C) parse D) decrement E) None of these
A
This operator increments the value of its operand, then uses the value in context. Question options: A) prefix increment B) prefix decrement C) postfix decrement D) postfix increment E) None of these
A
This term refers to the programmer reading the program from the beginning and stepping through each statement. Question options: A) spot checking B) desk checking C) pseudocoding D) software engineering E) None of these
A
This vector function returns the number of elements in a vector. Question options: A) size B) num_elements C) length D) elements
A
To read data from a file, you define an object of this data type. Question options: A) ifstream B) inputFile C) ofstream D) fstream
A
Using a linear search to find a value that is stored in the last element of an array of 20,000 elements, ________ element(s) must be compared. Question options: A) 20,000 B) only half C) 2000 D) only the first E) None of these
A
What does the following statement do? vector<int> v(10); Question options: A) It creates a vector object with a starting size of 10. B) It creates a vector object that can store only values of 10 or less. C) It creates a vector object and initializes all of its elements to the value 10. D) It creates a vector object and initializes the first element with the value 10.
A
What is the output of the following code segment? n = 1; for ( ; n <= 5; ) cout << n << ' '; n++; Question options: A) 1 1 1 ... and on forever B) 2 3 4 5 6 C) 2 3 4 5 D) 1 2 3 4 E) 1 2 3 4 5
A
What is the output of the following program? # include <iostream> using namespace std; int getValue(int); int main( ) { int x = 2; cout << getValue(x) << endl; return 0; } int getValue(int num) { return num + 5; } Question options: A) 7 B) 5 C) 2 D) "getValue(x)"
A
What is the output of the following segment of code if 4 is input by the user when asked to enter a number? int num; int total = 0; cout << "Enter a number from 1 to 10: "; cin >> num; switch (num) { case 1: case 2: total = 5; case 3: total = 10; case 4: total = total + 3; case 8: total = total + 6; default: total = total + 4; } cout << total << endl; Question options: A) 13 B) 3 C) 28 D) 0 E) None of these
A
What is the value of the following expression? true && false Question options: A) false B) +1 C) -1 D) true
A
What is the value stored at x, given the statements: int x; x = 3 / static_cast(4.5 + 6.4); Question options: A) 0 B) 3.3 C) .3 D) .275229 E) None of these
A
What will be the value of result after the following code has been executed? int a = 60; int b = 15; int result = 10; if (a = b) result *= 2; Question options: A) 20 B) 10 C) 120 D) This code will not compile.
A
What will following segment of code output? int x = 5; if (x = 2) cout << "This is true!" << endl; else cout << "This is false!" << endl; cout << "This is all folks!" << endl; Question options: A) This is true! This is all folks! B) This is true! This is false! C) This is false! D) This is true! E) None of these
A
What will the following code display? int x = 0, y = 1, z = 2; cout << x << y << z << endl; Question options: A) 012 B) 0 1 2 C) xyz D) 0 1 2
A
What will the following code output? int number = 22; int *var = &number; cout << *var << endl; Question options: A) 22 B) an asterisk followed by 22 C) an asterisk followed by the address of the number variable D) the address of the number variable
A
What will the following segment of code output? score = 40; if (score > 95) cout << "Congratulations!\n"; cout << "That's a high score!\n"; cout << "This is a test question!" << endl; Question options: A) That's a high score! This is a test question! B) Congratulations! That's a high score! This is a test question! C) This is a test question! D) Congratulations! That's a high score! E) None of these
A
What will the following statement output? cout << &num1; Question options: A) the memory address of the variable called num1 B) the string "&num1" C) the number 1 D) the value stored in the variable called num1 E) None of these
A
What will the value of x be after the following statements execute? int x; x = 18 % 4; Question options: A) 2 B) 0.45 C) 4 D) unknown
A
When a variable is assigned a number that is too large for its data type, it: Question options: A) overflows B) exceeds expectations C) underflows D) reverses polarity E) None of these
A
When converting some algebraic expressions to C++, you may need to insert ________ that do not appear in the algebraic expression. Question options: A) parentheses B) calculations C) exponents D) coercions E) None of these
A
When the less than ( < ) operator is used between two pointer variables, the expression is testing whether: Question options: A) the address of the first variable comes before the address of the second variable in the computer's memory B) the value pointed to by the first is greater than the value pointed to by the second C) the first variable was declared before the second variable D) the value pointed to by the first is less than the value pointed to by the second E) None of these
A
When using the new operator with an older compiler, it is good practice to: Question options: A) test the pointer for the NULL address B) clear the data from the old operator C) use a preprocessor directive D) All of these E) None of these
A
When writing functions that accept multi-dimensional arrays as arguments, ________ must be explicitly stated in the parameter list. Question options: A) all but the first dimension B) the size declarator of the first dimension C) all dimensions D) all element values E) None of these
A
When you work with a dereferenced pointer, you are actually working with: Question options: A) the actual value of the variable whose address is stored in the pointer variable B) a variable whose memory has been deallocated C) a copy of the value pointed to by the pointer variable D) All of these E) None of these
A
Which data type typically requires only one byte of storage? Question options: A) char B) short C) int D) double E) float
A
Which is true about the following statement? cout << setw(4) << num4 << " "; Question options: A) It allows four spaces for the value in the variable num4. B) It should use setw(10) to output the value in the variable num10. C) It inputs up to four characters stored in the variable num4. D) It outputs "setw(4)" before the value in the variable num4. E) None of these
A
Which line in the following program contains a call to the showDub function? 1 #include <iostream> 2 using namespace std; 3 4 void showDub(int); 5 6 int main( ) 7 { 8 int x = 2; 9 10 showDub(x); 11 cout << x << endl; 12 return 0; 13 } 14 15 void showDub(int num) 16 { 17 cout << (num * 2) << endl; 18 } Question options: A) 10 B) 15 C) 6 D) 4
A
Which line in the following program contains the prototype for the showDub function? 1 # include <iostream> 2 using namespace std; 3 4 void showDub(int); 5 6 int main( ) 7 { 8 int x = 2; 9 10 showDub(x); 11 cout << x << endl; 12 return 0; 13 } 14 15 void showDub(int num) 16 { 17 cout << (num * 2) << endl; 18 } Question options: A) 4 B) 10 C) 15 D) 6
A
Which of the following defines a double-precision floating point variable named payCheck? Question options: A) float payCheck; B) payCheck double; C) Double payCheck; D) double payCheck;
A
Which of the following is a preprocessor directive? Question options: A) #include <iostream> B) // This program calculates the user's pay. C) pay = hours * rate; D) cin >> rate; E) int main( )
A
Which of the following is not one of the five major components of a computer system? Question options: A) preprocessor B) input/output device C) main memory D) the CPU (central processing unit) E) secondary storage device
A
Which statement displays the address of the variable num1? Question options: A) cout << &num1; B) cin >> &num1; C) cout << num1; D) cout << *num1; E) None of these
A
With pointer variables, you can ________ manipulate data stored in other variables. Question options: A) indirectly B) seldom C) never D) All of these E) None of these
A
________ algorithms are used to arrange random data into some order. Question options: A) Sorting B) Linear C) Standard search D) Binary search E) None of these
A
A ________ variable is declared outside all functions. Question options: A) counter B) global C) floating-point D) local E) None of these
B
A pointer may be initialized with: Question options: A) the value of an integer variable B) the address of an existing object C) the value of a floating point variable D) All of these E) None of these
B
A two-dimensional array can be viewed as ________ and ________. Question options: A) arguments, parameters B) rows, columns C) increments, decrements D) All of these E) None of these
B
A variable declaration announces the name of a variable that will be used in a program, as well as: Question options: A) the area of the code in which it will be used B) the type of data it will be used to hold C) the number of times it will be used in the program D) the operators that will be used on it E) None of these
B
A variable whose value can be either true or false is of this data type. Question options: A) T/F B) bool C) float D) binary E) None of these
B
A(n) ________ can be used to specify the starting values of an array. Question options: A) element B) initialization list C) subscript D) array name E) None of these
B
A(n) ________ is a set of instructions that the computer follows to solve a problem. Question options: A) operator B) program C) compiler D) linker E) None of these
B
An Integrated Development Environment typically consists of: Question options: A) a debugger B) a compiler C) a text editor D) All of the above E) None of these
B
An array can easily be stepped through by using a: Question options: A) reference variable B) for loop C) named constant D) null value E) none of these
B
An array can store a group of values, but the values must be: Question options: A) constants B) the same data type C) each of a different data type D) integers E) None of these
B
An example of a secondary storage device is: Question options: A) the computer's main memory B) a hard disk C) the monitor D) The keyboard E) None of these
B
Arrays may be ________ at the time they are ________. Question options: A) pre-compiled, typecast B) initialized, declared C) resized, executed D) re-scoped, deleted E) None of these
B
Associativity is either right to left or: Question options: A) front to back B) left to right C) top to bottom D) undeterminable E) None of these
B
Assume that a program has the following string object definition: string name; Which of the following statements correctly assigns a string literal to the string object? Question options: A) name = (Jane); B) name = "Jane"; C) name = 'Jane'; D) name = Jane;
B
Assuming ptr is a pointer variable, what will the following statement output? cout << *ptr; Question options: A) the address of the variable stored in ptr B) the value stored in the variable whose address is contained in ptr C) the address of the variable whose address is stored in ptr D) the string "*ptr" E) None of these
B
Assuming x is 5, y is 6, and z is 8, which of the following is false? 1. x == 5; 2. 7 <= (x + 2); 3. z < = 4; 4. (1 + x) != y; 5. z >= 8; 6. x >= 0; 7. x <= (y * 2) Question options: A) 3, 4, 6, 7 are false. B) 3 and 4 are false. C) Only 5 is false. D) All are false. E) None of these
B
Characters or symbols that perform operations on one or more operands are: Question options: A) op codes B) operators C) program ops D) syntax E) None of these
B
For every opening brace in a C++ program, there must be a: Question options: A) string literal B) closing brace C) variable D) function E) None of these
B
Given the following function definition void calc (int a, int& b) { int c; c = a + 2; a = a * 3; b = c + a; } What is the output of the following code fragment that invokes calc? (All variables are of type int) x = 1; y = 2; z = 3; calc(x, y); cout << x << " " << y << " " << z << endl; Question options: A) 1 14 9 B) 1 6 3 C) 3 6 3 D) 1 2 3 E) None of these
B
How many elements does the following array have? int bugs[1000]; Question options: A) 1001 B) 1000 C) 999 D) cannot tell from the code
B
If you use a C++ key word as an identifier, your program will: Question options: A) execute with unpredictable results B) not compile C) compile, link, but not execute D) understand the difference and run without problems E) None of these
B
If you want a user to enter exactly 20 values, which loop would be the best to use? Question options: A) infinite B) for C) while D) do-while E) None of these
B
In programming terms, a group of characters inside a set of quotation marks is called a: Question options: A) variable B) string literal C) operation D) statement E) None of these
B
In the C++ instruction, cookies = number % children; given the following declaration statement: int number = 38, children = 4, cookies; what is the value of cookies after the execution of the statement? Question options: A) 0 B) 2 C) 9 D) .5 E) None of these
B
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? Question options: A) ptr will hold the address of the 2nd byte within the element numbers[0] B) ptr will hold the address of numbers[1] C) ptr will hold the address of numbers[0] D) This code will not compile.
B
Look at the following function prototype. int myFunction(double); What is the data type of the funtion's return value? Question options: A) double B) int C) void D) can't tell from the prototype
B
The computer's main memory is commonly known as: Question options: A) the hard disk B) RAM C) secondary storage D) the floppy disk E) None of these
B
The do-while loop is a ________ loop that is ideal in situations where you always want the loop to iterate at least once. Question options: A) infinite B) post-test C) pre-test D) null-terminated E) None of these
B
The name for a memory location that may hold data is: Question options: A) syntax B) variable C) key word D) operator E) None of these
B
The name of an array stores the ________ of the first array element. Question options: A) value B) memory address C) element number D) data type E) None of these
B
The programmer usually enters source code into a computer using: Question options: A) pseudocode B) a text editor C) a compiler D) a hierarchy chart E) None of these
B
The purpose of a memory address is: Question options: A) to obtain an algorithm B) to identify the location of a byte in memory C) to prevent multitasking D) to improve the effectiveness of high-level languages E) None of these
B
The statement cin >> setw(10) >> str; will read up to this many characters into str. Question options: A) eleven B) nine C) eight D) ten E) None of these
B
The statement int grades[ ] = { 100, 90, 99, 80}; shows an example of: Question options: A) an illegal array initialization B) implicit array sizing C) default arguments D) an illegal array declaration E) None of these
B
The statement int *ptr = new int; Question options: A) creates a new pointer named int B) assigns an address to the variable named ptr C) assigns an integer less than 32767 to the variable named ptr D) results in a compiler error E) None of these
B
The statements in the body of a while loop may never be executed, whereas the statements in the body of a do-while loop will be executed: Question options: A) never B) at least once C) at least twice D) as many times as the user wishes E) None of these
B
These can be used as pointers. Question options: A) Punctuation marks B) Array names C) Numeric constants D) All of these E) None of these
B
These types of arguments are passed to parameters automatically if no argument is provided in the function call. Question options: A) local B) default C) relational D) global E) None of these
B
This is a collection of statements that performs a specific task. Question options: A) infinite loop B) function C) variable D) constant E) None of these
B
This is a complete instruction that causes the computer to perform some action. Question options: A) line B) statement C) key word D) variable E) None of these
B
This is a variable that is regularly incremented or decremented each time a loop iterates. Question options: A) null terminator B) counter C) control statement D) constant E) None of these
B
This manipulator causes the field to be left-justified with padding spaces printed to the right. Question options: A) left_justify B) left C) right D) left_pad E) None of these
B
This manipulator is used to establish a field width for the value immediately following it. Question options: A) set_field B) setw C) field_width D) iomanip E) None of these
B
This operator is known as the logical OR operator. Question options: A) -- B) || C) # D) // E) None of these
B
This operator performs a logical NOT operation. Question options: A) >< B) ! C) -- D) <> E) None of these
B
This statement lets the value of a variable or expression determine where the program will branch to. Question options: A) select B) switch C) scope D) associative E) None of these
B
This statement may be used to stop a loop's current iteration and begin the next one. Question options: A) terminate B) continue C) break D) return E) None of these
B
This statement may be used to stop a loop's current iteration and begin the next one. Question options: A) terminate B) continue C) re-iterate D) break E) None of these
B
This step will uncover any syntax errors in your program. Question options: A) executing B) compiling C) linking D) editing E) None of these
B
This vector function is used to insert an item into a vector. Question options: A) store B) push_back C) add_item D) insert_item
B
This vector function returns true if the vector has no elements. Question options: A) has_no_elements B) empty C) null_size D) is_empty
B
Unlike regular variables, these can hold multiple values. Question options: A) named constants B) arrays C) constants D) floating-point variables E) None of these
B
What does the following statement do? double *num2; Question options: A) initializes a variable named *num2 B) declares a pointer variable named num2 C) declares and initializes an pointer variable named num2 D) declares a double variable named num2 E) None of these
B
What is the last legal subscript that can be used with the following array? int values[5]; Question options: A) 6 B) 4 C) 5 D) 0
B
What is the output of the following code? int w = 98; int x = 99; int y = 0; int z = 1; if (x >= 99) { if (x < 99) cout << y << endl; else cout << z << endl; } else { if (x == 99) cout << x << endl; else cout << w << endl; } Question options: A) 99 B) 1 C) 0 D) 98
B
What is the output of the following program? # include <iostream> using namespace std; void doSomething(int&); int main( ) { int x = 2; cout << x << endl; doSomething(x); cout << x << endl; return 0; } void doSomething(int& num) { num = 0; cout << num << endl; } Question options: A) 2 2 2 B) 2 0 0 C) 2 0 2 D) 0 0 0
B
What is the output of the following program? # include <iostream> using namespace std; void doSomething(int); int main( ) { int x = 2; cout << x << endl; doSomething(x); cout << x << endl; return 0; } void doSomething(int num) { num = 0; cout << num << endl; } Question options: A) 2 2 2 B) 2 0 2 C) 0 0 0 D) 2 0 0
B
What is the value of donuts after the following code executes? int donuts = 10; if (donuts != 10) donuts = 0; else donuts += 2; Question options: A) 2 B) 12 C) 0 D) 10
B
What is the value of number after the following statements execute? int number = 10; number += 5; number -= 2; number *= 3; Question options: A) 2 B) 15 C) 30 D) 3
B
What is the value of the following expression? false || true Question options: A) +1 B) true C) -1 D) false
B
What is the value of the following expression? true || true Question options: A) -1 B) true C) +1 D) false
B
What will be the output of the following code segment after the user enters 0 at the keyboard? int x = -1; cout << "Enter a 0 or a 1 from the keyboard: "; cin >> x; if (x) cout << "true" << endl; else cout << "false" << endl; Question options: A) Nothing will be displayed. B) false C) true D) x
B
What will the following code display? cout << "Four\n" << "score\n"; cout << "and" << "\nseven"; cout << "\nyears" << " ago" << endl; Question options: A) Four score and seven years ago B) Four score and seven years ago C) Four score and seven years ago D) Four score and seven years ago
B
What will the following code display? int number = 6 int x = 0; x = --number; cout << x << endl; Question options: A) 7 B) 5 C) 6 D) 0
B
What will the following code display? int number = 6; cout << ++number << endl; Question options: A) 5 B) 7 C) 0 D) 6
B
What will the following code display? int number = 6; cout << number++ << endl; Question options: A) 0 B) 6 C) 5 D) 7
B
What will the following code display? int number = 6; int x = 0; x = number--; cout << x << endl; Question options: A) 7 B) 6 C) 5 D) 0
B
What will the following loop display? int x = 0; while (x < 5) { cout << x << endl; x++; } Question options: A) 0 1 2 3 4 5 B) 0 1 2 3 4 C) 01 2 3 4 D) The loop will display numbers starting at 0, for infinity.
B
What will the following program display? # include <iostream> using namespace std; int main( ) { int a = 0, b = 2, x = 4, y = 0; cout << (a == b) << " "; cout << (a != b) << " "; cout << (b <=x) << " "; cout << (y > a) << endl; return 0; } Question options: A) 1 0 0 1 B) 0 1 1 0 C) 1 1 0 1 D) 0 0 1 0 E) None of these
B
What will the value of result be after the following statement executes? result = 6 - 3 * 2 + 7 - 10 / 2 ; Question options: A) 8 B) 2 C) 6 D) 1.5
B
When a relational expression is false, it has the value ________. Question options: A) one B) zero C) zero, one, or minus one D) less than zero E) None of these
B
When the final value of an expression is assigned to a variable, it will be converted to: Question options: A) the largest C++ data type B) the data type of the variable C) the data type of the expression D) the smallest C++ data type E) None of these
B
When this operator is used with string operands it concatenates them, or joins them together. Question options: A) & B) + C) * D) % E) None of these
B
When used as parameters, these types of variables allow a function to access the parameter's original argument. Question options: A) counter B) reference C) undeclared D) floating-point E) None of these
B
Which line in the following program contains the header for the showDub function? 1 #include <iostream> 2 using namespace std; 3 4 void showDub(int); 5 6 int main( ) 7 { 8 int x = 2; 9 10 showDub(x); 11 cout << x << endl; 12 return 0; 13 } 14 15 void showDub(int num) 16 { 17 cout << (num * 2) << endl; 18 } Question options: A) 6 B) 15 C) 4 D) 10
B
Which line in the following program will cause a compiler error? 1 #include <iostream> 2 using namespace std; 3 4 int main( ) 5 { 6 const int MY_VAL = 77; 7 MY_VAL = 99; 8 cout << MY_VAL << endl; 9 return 0; 10 } Question options: A) 8 B) 7 C) 6 D) 9
B
Which line in the following program will cause a compiler error? 1 #include <iostream> 2 using namespace std; 3 4 int main( ) 5 { 6 int number = 5; 7 8 if (number >= 0 && <= 100) 9 cout << "passed.\n"; 10 else 11 cout << "failed.\n"; 12 return 0; 13 } Question options: A) 10 B) 8 C) 6 D) 9
B
Which of the following statements deletes memory that has been dynamically allocated for an array? Question options: A) new array = delete; B) delete [ ] array; C) int array = delete memory; D) int delete[ ]; E) None of these
B
Which one of the following would be an illegal variable name? Question options: A) itemsorderedforthemonth B) 3dGraph C) June1997 D) employee_num E) dayOfWeek
B
Which statement is equivalent to the following? number += 1; Question options: A) number + 1; B) number = number + 1; C) number = 1; D) None of these
B
Which statement is equivalent to the following? x = x * 2; Question options: A) x = x * x; B) x *= 2; C) x * 2; D) None of these
B
Which value can be entered to cause the following code segment to display the message "That number is acceptable." int number; cin >> number; if (number > 10 && number < 100) cout << "That number is acceptable.\n"; else cout << "That number is not acceptable.\n"; Question options: A) 100 B) 99 C) 0 D) 10 E) All of these
B
You can use these to override the rules of operator precedence in a mathematical expression. Question options: A) {braces} B) (parentheses) C) the escape character \ D) [brackets] E) None of these
B
You may define a ________ in the initialization expression of a for loop. Question options: A) new data type B) variable C) function D) constant E) None of these
B
________ functions may have the same name, as long as their parameter lists are different. Question options: A) Only two B) Two or more C) Un-prototyped D) Zero E) None of these
B
________ must be included in any program that uses the cout object. Question options: A) Escape sequences B) The header file iostream C) Comments D) Opening and closing braces E) None of these
B
________ represent storage locations in the computer's memory. Question options: A) Comments B) Variables C) Literals D) Integers E) None of these
B
A binary search begins with the ________ element of an array. Question options: A) largest B) first C) middle D) last E) None of these
C
A character literal is enclosed in ________ quotation marks, whereas a string literal is enclosed in ________ quotation marks. Question options: A) double, single B) triple, double C) single, double D) open, closed E) None of these
C
A for statement contains three expressions: initialization, test, and: Question options: A) null B) validation C) update D) reversal E) None of these
C
A function is executed when it is: Question options: A) defined B) declared C) called D) prototyped E) None of these
C
A(n) ________ is information that is passed to a function, and a(n) ________ is information that is received by a function. Question options: A) parameter, argument B) function call, function header C) argument, parameter D) prototype, header E) None of these
C
An array of string objects that will hold 5 names would be declared using which statement? Question options: A) string names(5); B) string names5; C) string names[5]; D) String[5] names; E) None of these will work.
C
An array's size declarator must be a(n)________ with a value greater than ________. Question options: A) number, zero B) number, one C) constant integer expression, zero D) variable, -1 E) None of these
C
Assume that a program has the following variable definition: char letter; Which of the following statements correctly assigns the character Z to the variable? Question options: A) letter = "Z"; B) letter = (Z); C) letter = 'Z'; D) letter = Z;
C
Assuming dataFile is a file stream object, the statement dataFile.close(); Question options: A) is legal but risks losing valuable data B) is illegal in C++ C) closes a file D) needs a filename argument to execute correctly E) None of these
C
By using the same ________ you can build relationships between data stored in two or more arrays. Question options: A) arguments B) array name C) subscript D) data E) None of these
C
EXIT_FAILURE and ________ are named constants that may be used to indicate success or failure when the exit( ) function is called. Question options: A) EXIT_TERMINATE B) RETURN_OK C) EXIT_SUCCESS D) EXIT_OK E) None of these
C
Functions are ideal for use in menu-driven programs. When a user selects a menu item, the program can ________ the appropriate function. Question options: A) define B) prototype C) call D) declare E) None of these
C
Given the following code segment, what is output after "result = "? int x = 1, y = 1, z = 1; y = y + z; x = x + y; cout << "result = " << (x < y ? y : x) << endl; Question options: A) 1 B) 2 C) 3 D) 0 E) None of these
C
Given the following declaration, where is 77 stored in the scores array? int scores[ ]={83, 62, 77, 97}; Question options: A) scores [4] B) scores [1] C) scores [2] D) scores [0]
C
How many times will the following loop display "Hello"? for (int i = 0; i < 20; i++) cout << "Hello!" << endl; Question options: A) 19 B) 21 C) 20 D) an infinite number of times
C
How many times will the following loop display "Hello"? for (int i = 0; i <= 20; i++) cout << "Hello!" << endl; Question options: A) 19 B) 20 C) 21 D) an infinite number of times
C
How would you consolidate the following declaration statements into one statement? int x = 7; int y = 16; int z = 28; Question options: A) int x, y, z = 7, 16, 28 B) int x = 7; y = 16; z = 28; C) int x = 7, y = 16, z = 28; D) int x = 7 y = 16 z = 28; E) None of these will work.
C
If a function does not have a prototype, default arguments may be specified in the function ________. Question options: A) execution B) call C) header D) return type E) None of these
C
If you intend to place a block of statements within an if statement, you must place these around the block. Question options: A) quotation marks " " B) parentheses ( ) C) curly braces { } D) square brackets [ ] E) None of these
C
If you place a semicolon after the statement if (x < y) Question options: A) the code will not compile B) the if statement will always evaluate to false C) the compiler will interpret the semicolon as a null statement D) All of the above E) None of these
C
If you place a semicolon after the test expression in a while loop, it is assumed to be a(n): Question options: A) infinite loop B) post-test loop C) null statement D) pre-test loop E) None of these
C
In a broad sense, the two primary categories of programming languages are: Question options: A) COBOL and BASIC B) mainframe and PC C) low-level and high-level D) single-tasking and multi-tasking E) None of these
C
In any program that uses the cin object, you must include the ________. Question options: A) linker B) compiler C) iostream header file D) >> and << operators E) None of these
C
In the following C++ statement, what will be executed first according to the order of precedence? result = 6 - 3 * 2 + 7 - 10 / 2 ; Question options: A) 10 / 2 B) 7 - 10 C) 3 * 2 D) 2 + 7 E) 6 - 3
C
It is ________ to pass an argument to a function that contains an individual array element, such as numbers[3]. Question options: A) illegal in C++ B) not recommended by the ANSI committee C) legal in C++ D) not good programming practice E) None of these
C
Look at the following function prototype. int myFunction(double); What is the data type of the funtion's parameter variable? Question options: A) void B) int C) double D) can't tell from the prototype
C
Look at the following statement: sum += *array++; This statement: Question options: A) increments the dereferenced pointer's value by one, then assigns that value B) is illegal in C++ C) assigns the dereferenced pointer's value, then increments the pointer's address D) will always result in a compiler error E) None of these
C
Something within a while loop must eventually cause the condition to become false, or a(n) ________ results. Question options: A) compiler error B) unexpected exit C) infinite loop D) null value E) None of these
C
The ________ causes the contents of another file to be inserted into a program. Question options: A) backslash B) semicolon C) # include directive D) pound sign E) None of these
C
The ________ is automatically appended to a character array when it is initialized with a string constant. Question options: A) number of elements B) value of the first element C) null terminator D) array name E) None of these
C
The ________ operator always follows the cin object, and the ________ operator follows the cout object. Question options: A) conditional, binary B) binary, unary C) >>, << D) <<, >> E) None of these
C
The ________ sort usually performs fewer exchanges than the ________ sort. Question options: A) binary, linear B) bubble, selection C) selection, bubble D) ANSI, ASCII E) None of these
C
The advantage of a linear search is its: Question options: A) complexity B) speed C) simplicity D) efficiency E) None of these
C
The contents of pointer variables may be changed with mathematical statements that perform: Question options: 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
The programming process consists of several steps, which include: Question options: A) syntax, logic, and error handling B) input, processing, and output C) design, creation, testing, and debugging D) key words, operators, and punctuation E) None of these
C
The value in a(n) ________ variable persists between function calls. Question options: A) local B) dynamic C) static local D) counter
C
The value in this type of local variable persists between function calls. Question options: A) dynamic B) internal C) static D) global E) None of these
C
These are data items whose values do not change while the program is running. Question options: A) comments B) variables C) literals D) integers E) None of these
C
These are used to declare variables that can hold real numbers. Question options: A) real data types B) long data types C) floating point data types D) integer data types E) None of these
C
This function causes a program to terminate, regardless of which function or control mechanism is executing. Question options: A) continue( ) B) return( ) C) exit( ) D) terminate( ) E) None of these
C
This is a control structure that causes a statement or group of statements to repeat. Question options: A) decision statement B) cout object C) loop D) constant E) None of these
C
This is a dummy function that is called instead of the actual function it represents. Question options: A) driver B) main function C) stub D) overloaded function
C
This is a set of rules that must be followed when constructing a program. Question options: A) portability B) punctuation C) syntax D) operators E) key words
C
This is a statement that causes a function to execute. Question options: A) function prototype B) for loop C) function call D) do-while loop E) None of these
C
This operator is used in C++ to represent equality. Question options: A) >< B) !! C) == D) = E) None of these
C
This statement causes a loop to terminate early. Question options: A) stop B) terminate C) break D) null E) None of these
C
This type of variable is defined inside a function and is not accessible outside the function. Question options: A) counter B) global C) local D) reference E) None of these
C
This vector function removes an item from a vector. Question options: A) delete_item B) erase C) pop_back D) remove_item
C
To access an array element, use the array name and the element's: Question options: A) value B) name C) subscript D) data type E) None of these
C
To assign the contents of one array to another, you must use: Question options: A) the equality operator with the array names B) the assignment 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
To pass an array as an argument to a function, pass the ________ of the array. Question options: A) contents B) value of the first element C) name D) size, expressed as an integer E) none of these
C
Unix and Windows 2000 are examples of ________ operating systems. Question options: A) multi-tasking B) single tasking C) command-driven D) Macintosh E) None of these
C
Use the delete operator only on pointers that were: Question options: A) dereferenced inappropriately B) not correctly initialized C) created with the new operator D) never used E) None of these
C
What is the output of the following code segment? n = 1; while (n <= 5) cout << n << ' '; n++; Question options: A) 2 3 4 5 6 B) 1 2 3 4 5 C) 1 1 1... and on forever D) 1 2 3 4 E) 2 3 4 5
C
What will the following code display? int number = 6; ++number; cout << number << endl; Question options: A) 0 B) 6 C) 7 D) 5
C
What will the following code display? int number = 7; cout << "The number is " << "number" << endl; Question options: A) The number is 7 B) The number is7 C) The number is number D) The number is 0
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; Question options: A) 87 66 55 101 B) 99 87 66 55 101 C) 87 66 55 D) Nothing. This code has an error.
C
What will the following code display? int numbers[ ] = {99, 87, 66, 55, 101 }; cout << numbers[3] << endl; Question options: A) 66 B) 87 C) 55 D) 101
C
What will the following code display? int numbers[4] = { 99, 87 }; cout << numbers[3] << endl; Question options: A) garbage B) 87 C) 0 D) This code will not compile.
C
What will the following code display? int x = 0; for (int count = 0; count < 3; count++) x += count; cout << x << endl; Question options: A) 6 B) 0 C) 3 D) 0 1 2
C
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; Question options: A) five memory addresses B) 1 C) 2 D) 3 E) 0
C
What will the following segment of code output? You can assume the user enters a grade of 90 from the keyboard. cout << "Enter a test score: "; cin >> test_score; if (test_score < 60); cout << "You failed the test!" << endl; if (test_score > 60) cout << "You passed the test!" << endl; else cout << "You need to study for the next test!"; Question options: A) You failed the test! You did poorly on the test! B) You passed the test! C) You failed the test! You passed the test! D) You failed the test! E) None of these
C
What will the value of x be after the following statements execute? int x = 0; int y = 5; int z = 4; x = y + z * 2; Question options: A) 18 B) 0 C) 13 D) unknown
C
What will the value of x be after the following statements execute? int x; x = 18 / 4; Question options: A) 0 B) 4.5 C) 4 D) unknown
C
What will the value of x be after the following statements execute? int x; x = 18.0 / 4; Question options: A) 4.5 B) 0 C) 4 D) unknown
C
When a program lets the user know that an invalid choice has been made, this is known as: Question options: A) compiler criticism B) output correction C) input validation D) output validation E) None of these
C
Which escape sequence causes the cursor to move to the beginning of the current line? Question options: A) \b B) \n C) \r D) \t E) \a
C
Which line in the following program will cause a compiler error? 1 #include <iostream> 2 using namespace std; 3 4 int main( ) 5 { 6 const int MY_VAL; 7 MY_VAL = 77; 8 cout << MY_VAL << endl; 9 return 0; 10 } Question options: A) 7 B) 8 C) 6 D) 9
C
Which of the following expressions will determine whether x is less than or equal to y? Question options: A) x =< y B) x > y C) x <= y D) x >= y
C
Which of the following statements about global variables is true? Question options: A) A global variable is declared in the highest-level block in which it is used. B) A global variable is accessible only to the main function. C) A global variable can have the same name as a variable that is declared locally within a function. D) If a function contains a local variable with the same name as a global variable, the global variable's name takes precedence within the function. E) All of these are true
C
Which statement allows you to properly check the char variable code to determine whether it is equal to a "C" and then output "This is a check" and then advance to a new line? Question options: A) if code is equal to C cout << "This is a check\n"; B) if (code = "C") cout << "This is a check" << endl; C) if (code == 'C') cout << "This is a check\n"; D) if (code == C) cout << "This is a check" << endl;
C
Words that have a special meaning and may be used only for their intended purpose are known as: Question options: A) syntax B) programmer defined words C) key words D) operators E) None of these
C
A ________ algorithm is a method of locating a specific item of information in a larger collection of data. Question options: A) linear B) sort C) standard D) search E) None of these
D
A file ________ is a small holding section of memory that file-bound information is first written to. Question options: A) segment B) name C) number D) buffer E) None of these
D
A file must be ________ before data can be written to or read from it. Question options: A) buffered B) closed C) initialized D) opened E) None of these
D
A function ________ eliminates the need to place a function definition before all calls to the function. Question options: A) argument B) header C) parameter D) prototype E) None of these
D
A function can have zero to many parameters, and it can return this many values. Question options: A) no B) a maximum of ten C) zero to many D) only one E) None of these
D
A pointer variable is designed to store: Question options: A) any legal C++ value B) an integer C) only floating-point values D) a memory address E) None of these
D
A set of well-defined steps for performing a task or solving a problem is known as a(n): Question options: A) hierarchy B) central processing unit C) encoded instruction D) algorithm E) None of these
D
A statement that starts with a # is called a: Question options: A) function B) comment C) key word D) preprocessor directive E) None of these
D
A two-dimensional array of characters can contain: Question options: A) uninitialized elements B) strings of different lengths C) strings of the same length D) All of these E) None of these
D
A variable's __________ is the part of the program that has access to the variable. Question options: A) data type B) reach C) value D) scope E) None of these
D
A(n) ________ argument is passed to a parameter when the actual argument is left out of the function call. Question options: A) true B) false C) null D) default E) None of these
D
A(n) ________ search uses a loop to sequentially step through an array. Question options: A) binary B) unary C) relative D) linear E) None of these
D
Assume that x is an int variable. What value is assigned to x after the following assignment statement is executed? x = -3 + 4 % 6 / 5; Question options: A) 1 B) 2 C) 0 D) -3 E) None of these
D
Assuming you are using a system with 1-byte characters, how many bytes of memory will the following string literal occupy? "William" Question options: A) 1 B) 7 C) 14 D) 8
D
At the heart of a computer is its central processing unit. The CPU's job is: Question options: A)to produce some outcome or resultant information B) to fetch instructions C) to carry out the operations commanded by the instructions D) All of the above E) None of these
D
Besides decimal, two other number systems you might encounter in C++ programs are: Question options: A) unary and quaternary B) octal and fractal C) base 7 and base 9 D) hexadecimal and octal E) None of these
D
Character constants in C++ are always enclosed in ________. Question options: A) "double quotation marks" B) [brackets] C) (parentheses) D) 'single quotation marks' E) {braces}
D
Data that is sorted in ascending order is ordered: Question options: A) always with a linear sort algorithm B) always with a binary sort algorithm C) from highest to lowest value D) from lowest to highest value E) None of these
D
During which stage does the central processing unit analyze the instruction and encode it in the form of a number, and then generate an electronic signal? Question options: A) fetch B) execute C) portability stage D) decode
D
Every byte in the computer's memory is assigned a unique: Question options: A) name B) dynamic allocation C) pointer D) address E) None of these
D
Every complete C++ program must have a __________. Question options: A) comment B) symbolic constant C) preprocessor directive D) function named main E) cout statement
D
If a variable uses more than one byte of memory, for pointer purposes its address is: Question options: A) the average of the addresses used to store the variable B) general delivery C) the address of the last byte of storage D) the address of the first byte of storage E) None of these
D
In a C++ program, two slash marks ( // ) indicate: Question options: A) the end of a statement B) the beginning of a block of code C) the end of the program D) the beginning of a comment E) None of these
D
In memory, C++ automatically places a ________ at the end of string literals. Question options: A) semicolon B) quotation marks C) newline escape sequence D) null terminator E) None of these
D
In the process of translating a source file into an executable file, which of the following is the correct sequence? Question options: A) source code, linker, object code, compiler, modified source code, preprocessor, executable code B) source code, compiler, modified source code, preprocessor, object code, linker, executable code C) source code, preprocessor, modified source code, linker, object code, compiler, executable code D) source code, preprocessor, modified source code, compiler, object code, linker, executable code E) preprocessor, source code, compiler, executable code, linker, modified source code, object code
D
Input values should always be checked for: Question options: A) reasonableness B) division by zero, if division is taking place C) appropriate range D) All of these E) None of these
D
It is a good programming practice to ________ your functions by writing comments that describe what they do. Question options: A) eliminate B) prototype C) execute D) document E) None of these
D
Not all arithmetic operations may be performed on pointers. For example, you cannot ________ or ________ a pointer. Question options: A) increment, decrement B) add, subtract C) +=, -= D) multiply, divide E) None of these
D
Relational operators allow you to ________ numbers. Question options: A) average B) multiply C) add D) compare E) None of these
D
Subscript numbering in C++ Question options: A) varies from program to program B) can be set at runtime C) can begin with a programmer-defined value D) begins with zero E) None of these
D
The ________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed. Question options: A) cout object B) output stream C) preprocessor D) cin object E) None of these
D
The ________ is/are used to display information on the computer's screen. Question options: A) opening and closing quotation marks B) backslash C) opening and closing braces D) cout object E) None of these
D
The ________, also known as the address operator, returns the memory address of a variable. Question options: A) percent sign (%) B) asterisk ( * ) C) exclamation point ( ! ) D) ampersand ( & ) E) None of these
D
The do-while loop is considered a(n) ________ loop. Question options: A) pre-test B) infinite C) limited D) post-test E) None of these
D
The first step in using the string class is to #include the ________ header file. Question options: A) iostream B) cctype C) cmath D) string E) None of the above
D
The function, pow(x, 5.0), requires this header file. Question options: A) iomanip B) cstring C) cstdlib D) cmath E) iostream
D
The numeric data types in C++ can be broken into two general categories: Question options: A) numbers and characters B) singles and doubles C) real and unreal D) integer and floating point E) None of these
D
The statements written by the programmer are called: Question options: A) object code B) syntax C) runtime libraries D) source code E) None of these
D
The total number of digits that appear before and after the decimal point is sometimes referred to as: Question options: A) floating points B) significant digits C) precision D) B and C E) None of these
D
The while loop is this type of loop. Question options: A) limited B) post-test C) infinite D) pre-test E) None of these
D
These are operators that add and subtract one from their operands. Question options: A) conditional and relational B) binary and unary C) plus and minus D) ++ and -- E) None of these
D
These operators connect two or more relational expressions into one, or reverse the logic of an expression. Question options: A) irrational B) negation C) relational D) logical E) None of these
D
This function in C++ allows you to identify how many bytes of storage on your computer system an integer data value requires. Question options: A) bytes B) int C) f(x) D) sizeof E) len
D
This is a pre-test loop that is ideal in situations where you do not want the loop to iterate if the condition is false from the beginning. Question options: A) infinite B) do-while C) for D) while E) None of these
D
This is a variable, usually a boolean or an integer, that signals when a condition exists. Question options: A) relational operator B) arithmetic operator C) float D) flag E) None of these
D
This loop is a good choice when you know how many times you want the loop to iterate in advance of entering the loop. Question options: A) while B) do-while C) infinite D) for E) None of these
D
This may be used to write information to a file. Question options: A) output object B) cout object C) pen object D) stream insertion operator E) None of these
D
This operator represents the logical AND. Question options: A) @ B) || C) ++ D) && E) None of these
D
This operator takes an operand and reverses its truth or falsehood. Question options: A) arithmetic B) relational C) || D) ! E) None of these
D
This statement causes a function to end. Question options: A) end B) terminate C) release D) return E) None of these
D
This stream manipulator forces cout to print the digits in fixed-point notation. Question options: A) setfixed(2) B) setprecision(2) C) setw(2) D) fixed E) None of these
D
Three primary activities of a program are: Question options: A) integer, floating-point, and character B) variables, operators, and key words C) lines, statements, and punctuation D) input, processing, and output E) None of these
D
To allow file access in a program, you must #include this header file. Question options: A) file B) cfile C) fileaccess D) fstream
D
To write data to a file, you define an object of this data type. Question options: A) outputFile B) fstream C) ifstream D) ofstream
D
What does the term hardware refer to? a) the logical flow of instructions b) the physical components that a computer is made of c) the way a computer's storage space is organized d) the relative difficulty of programming e) None of these
D
What is assigned to the variable a given the statement below with the following assumptions: x = 10, y = 7, and z, a, and b are all int variables. a = x >= y; Question options: A) 7 B) 0 C) 10 D) 1 E) The string "x >= y"
D
What is the output of the following program? # include <iostream> using namespace std; void showDub(int); int main( ) { int x = 2; showDub(x); cout << x << endl; return 0; } void showDub(int num) { cout << (num * 2) << endl; } Question options: A) 2 2 B) 2 4 C) 4 4 D) 4 2
D
What is the output of the following statement? cout << 4 * (15 / (1 + 3)) << endl; Question options: A) 63 B) 72 C) 15 D) 12 E) None of these
D
What is the value of average after the following code executes? double average; average = 1.0 + 2.0 + 3.0 / 3.0; Question options: A) 6.0 B) 2.0 C) 1.5 D) 4.0
D
What is the value of donuts after the following code executes? int donuts = 10; if (donuts = 1) donuts = 0; else donuts += 2; Question options: A) 1 B) 12 C) 10 D) 0
D
What is the value of the following expression? true && true Question options: A) false B) -1 C) +1 D) true
D
What statement best describes a variable and its primary purpose? Question options: A) A variable is a word that has a special meaning to the compiler. B) A variable is a "line" of code in the body of a program, that may change. C) A variable is a collection of eight bits. D) A variable is a named storage location in the computer's memory used for holding a piece of information. E) A variable is a structured, general-purpose language designed primarily for teaching programming.
D
What will the following code display? cout << "Four " << "score "; cout << "and " << "seven/n"; cout << "years" << "ago" << endl; Question options: A) Four score and seven yearsago B) Four score and seven yearsago C) Four score and seven years ago D) Four score and seven/nyearsago
D
What will the following code display? cout << "Four" << "score" << endl; cout << "and" << "seven" << endl; cout << "years" << "ago" << endl; Question options: A) Four score and seven years ago B) Fourscoreandsevenyearsago C) Four score and seven years ago D) Fourscore andseven yearsago
D
What will the following code display? cout << "Monday"; cout << "Tuesday"; cout << "Wednesday"; Question options: A) "Monday" "Tuesday" "Wednesday" B) Monday Tuesday Wednesday C) Monday Tuesday Wednesday D) MondayTuesdayWednesday
D
What will the following code display? int number = 6; number++; cout << number << endl; Question options: A) 6 B) 5 C) 0 D) 7
D
What will the following code do? const int SIZE = 5; double x[SIZE]; for(int i = 2; i <= SIZE; i++) { x[i] = 0.0; } Question options: A) Each element in the array, except the first, is initialized to 0.0. B) Each element in the array is initialized to 0.0. C) Each element in the array, except the first and the last, is initialized to 0.0. D) An error will occur when the code runs.
D
What will the following code output? int number = 22; int *var = &number; cout << var << endl; Question options: A) 22 B) an asterisk followed by the address of the number variable C) an asterisk followed by 22 D) the address of the number variable
D
What will the following segment of code output if 11 is entered at the keyboard? int number; cin >> number; if (number > 0) cout << "C++"; else cout << "Soccer"; cout << " is "; cout << "fun" << endl; Question options: A) Soccer is fun B) C++fun C) C++ D) C++ is fun E) Soccerfun
D
When an array is sorted from highest to lowest, it is said to be in ________ order. Question options: A) forward B) reverse C) ascending D) descending E) None of these
D
When an if statement is placed within the conditionally-executed code of another if statement, this is known as: Question options: A) overloading B) complexity C) validation D) nesting E) None of these
D
When the increment operator precedes its operand, as in ++num1, the expression is in this mode. Question options: A) postfix B) preliminary C) binary D) prefix E) None of these
D
When this is placed in front of a variable name, it returns the address of that variable. Question options: A) asterisk ( * ) B) semicolon ( ; ) C) conditional operator D) ampersand ( & ) E) None of these
D
When using the sqrt function you must include this header file. Question options: A) cstdlib B) cstring C) iostream D) cmath E) iomanip
D
Whereas < is called a relational operator, x < y is called a(n) ________. Question options: A) relative operator B) arithmetic operator C) largeness test D) relational expression E) None of these
D
Which character signifies the beginning of an escape sequence? Question options: A) # B) // C) { D) \ E) /
D
Which of the following is a valid C++ array definition? Question options: A) float $payments[10]; B) int readings[4.5]; C) int scores[0]; D) int scores [10]; E) None of these
D
Which of the following is a valid C++ array definition? Question options: A) int array[0]; B) void numbers[5]; C) float $payments[10]; D) int array[10]; E) None of these
D
Which statement correctly defines a vector object for holding integers? Question options: A) int<vector> v; B) vector v<int>; C) int vector v; D) vector<int> v;
D
Which statement will read an entire line of input into the following string object? string address; Question options: A) cin.get(address); B) cin << address; C) cin address; D) getline(cin, address); E) None of these
D
Without this statement appearing in a switch construct, the program "falls through" all of the statements below the one with the matching case expression. Question options: A) exit B) switch C) scope D) break E) None of these
D
You must have a ________ for every variable you intend to use in a program. Question options: A) constant B) purpose C) comment D) definition E) None of these
D
You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written? Question options: A) cin >> length >> width >> height; B) cin >> length, width, height; C) cin << length, width, height; D) cin.get(length, width, height); E) cin << length; width; height;
D
________ are used to translate each source code instruction into the appropriate machine language instruction. Question options: A) Preprocessor directives B) Modules C) Library routines D) Compilers
D
________ reads a line of input, including leading and embedded spaces, and stores it in a string object. Question options: A) get B) cin.getline C) cin.get D) getline E) None of these
D
After execution of the following code, what will be the value of input_value if the value 0 is entered at the keyboard at run time? cin >> input_value; if (input_value > 5) input_value = input_value + 5; else if (input_value > 2) input_value = input_value + 10; else input_value = input_value + 15; Question options: A) 0 B) 5 C) 25 D) 10 E) 15
E
In a function header, you must furnish: Question options: A) the name of function B) data type of the return value C) data type(s) of the parameters D) names of parameter variables E) All of these
E
Of the following, which is a valid C++ identifier? Question options: A) myExtraLongVariableName B) _employee_number C) ___department D) June1997 E) All of the above are valid identifiers.
E
Regardless of the algorithm being used, a search through an array is always performed: Question options: A) using a binary search B) from highest to lowest element C) beginning with the middle element D) from lowest to highest element E) None of these
E
This control sequence is used to skip over to the next horizontal tab stop. Question options: A) \n B) \' C) \a D) \h E) \t
E
This statement will pause the screen, until the [Enter] key is pressed. Question options: A) cin.getline(); B) cin.input(); C) cin; D) cin.ignore(); E) cin.get();
E
What is the modulus operator? Question options: A) || B) & C) * D) + E) %
E
When you pass a pointer as an argument to a function, you must: Question options: A) not dereference the pointer in the function's body B) redeclare the pointer variable in the function call C) use the #include<func_ptr.h> statement D) dereference the pointer variable in the function prototype E) None of these
E
Which of the following best describes an operator? Question options: A) An operator is a symbolic name that refers to a variable. B) An operator is a word that has a special meaning. C) An operator marks the beginning or ending of a statement, or is used to separate items in a list. D) An operator is a rule that must be followed when constructing a program. E) An operator allows you to perform operations on one or more pieces of data.
E
Which of the following statements is not valid C++ code? Question options: A) int ptr = int *num1; B) int ptr = &num1; C) float num1 = &ptr2; D) All of these are valid. E) All of these are invalid.
E