Programming 1: Chapters 1-7

Ace your homework & exams now with Quizwiz!

This is a volatile type of memory, used for temporary storage. A) Address B) ALU C) RAM D) Disk drive E) None of the above

C

This operator represents the logical AND. A) ++ B) || C) && D) @ E) None of these

C

Which of the following is a preprocessor directive? A) pay = hours * rate; B) cin >> rate; C) // This program calculates the user's pay. D) int main() E) #include <iostream>

E

True/False: A local variable and a global variable may not have the same name within the same program.

FALSE

True/False: When writing long integer literals or long long integer literals in C++ 11, you can use either an uppercase or lowercase L.

TRUE

True/False: When you pass an array as an argument to a function, the function can modify the contents of the array.

TRUE

True/False: You may use the exit() function to terminate a program, regardless of which control mechanism is executing.

TRUE

In a for statement, this expression is executed only once. A) test B) null C) initialization D) validation E) None of these

C

Which character signifies the beginning of an escape sequence? A) // B) / C) \ D) # E) {

C

This is a collection of statements that performs a specific task. A) infinite loop B) variable C) constant D) function E) None of these

D

True/False: A variable called "average" should be declared as an integer data type because it will probably hold data that contains decimal places.

FALSE

True/False: A while loop is somewhat limited, because the counter can only be incremented by one each time through the loop.

FALSE

True/False: Although two-dimensional arrays are a novel idea, there is no known way to pass one to a function.

FALSE

True/False: An array initialization list must be placed on one single line.

FALSE

True/False: Arithmetic operators that share the same precedence have right to left associativity.

FALSE

True/False: Assume array1 and array2 are the names of arrays. To assign the contents of array2 to array1, you would use the following statement. array1 = array2;

FALSE

True/False: The scope of a variable declared in a for loop's initialization expression always extends beyond the body of the loop.

FALSE

Which of the following is a valid C++ array definition? A) int scores[0]; B) float $payments[10]; C) int readings[4.5]; D) int scores [10]; E) None of these

D

Which statement correctly defines a vector object for holding integers? A) vector v<int>; B) int vector v; C) int<vector> v; D) vector<int> v;

D

True/False: The following code correctly determines whether x contains a value in the range of 0 through 100. if (x >= 0 && <= 100)

FALSE

True/False: The following statement will output $5.00 to the screen: cout << setprecision(5) << dollars << endl;

FALSE

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

FALSE

True/False: The preprocessor executes after the compiler.

FALSE

True/False: The statement: double money[25.00]; is a valid C++ array definition.

FALSE

True/False: When a function is called, flow of control moves to the function's prototype.

FALSE

True/False: When a program uses the setw manipulator, the iosetwidth header file must be included in a preprocessor directive.

FALSE

True/False: You may nest while and do-while loops, but you may not nest for loops.

FALSE

True/False: You may not use the break and continue statements within the same set of nested loops.

FALSE

True/False: You must furnish an argument with a function call.

FALSE

True/False: Software engineering is a field that encompasses designing, writing, testing, debugging, documenting, modifying, and maintaining computer programs.

TRUE

True/False: The CPU is the most important component in a computer because without it, the computer could not run software.

TRUE

True/False: The amount of memory used by an array depends upon the array's data type and the number of elements in the array.

TRUE

True/False: The cin << statement will stop reading input when it encounters a newline character.

TRUE

True/False: When the fixed manipulator is used, the value specified by the setprecision manipulator will be the number of digits to appear after the decimal point.

TRUE

True/False: When typing in your source code into the computer, you must be very careful since most of your C++ instructions, header files, and variable names are case sensitive.

TRUE

True/False: You should be careful when using the equality operator to compare floating point values because of potential round-off errors.

TRUE

True/False: string objects have a member function named c_str that returns the contents of the object formatted as a null-terminated C-string.

TRUE

In programming terms, a group of characters inside a set of quotation marks is called a(n): A) String literal B) Variable C) Operation D) Statement E) None of the above

A

Look at the following function prototype. int myFunction(double); What is the data type of the function's return value? A) int B) double C) void D) Can't tell from the prototype

A

The do-while loop is a(n) ________ loop that is ideal in situations where you always want the loop to iterate at least once. A) post-test B) pre-test C) infinite D) null-terminated E) None of these

A

The float data type is considered ________ precision, and the double data type is considered ________ precision. A) single, double B) float, double C) integer, double D) short, long E) None of the above

A

The name of an array stores the ________ of the first array element. A) memory address B) value C) element number D) data type E) None of these

A

The purpose of a memory address is: A) To identify the location of a byte in memory B) To prevent multitasking C) To obtain an algorithm D) To improve the effectiveness of high-level languages E) None of the above

A

The statement: cin >> setw(10) >> str; will read up to this many characters into str. A) Nine B) Ten C) Eleven D) Eight E) None of these

A

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: A) at least once B) at least twice C) as many times as the user wishes D) never E) None of these

A

The while loop has two important parts: an expression that is tested for a true or false value, and: A) a statement or block that is repeated as long as the expression is true B) a statement or block that is repeated only if the expression is false C) one line of code that is repeated once, if the expression is true D) a statement or block that is repeated once, if the expression is true

A

These are data items whose values do not change while the program is running. A) Literals B) Variables C) Comments D) Integers E) None of the above

A

This function tells the cin object to skip one or more characters in the keyboard buffer. A) cin.ignore B) cin.jump C) cin.hop D) cin.skip; E) None of the above

A

This is a set of rules that must be followed when constructing a program. A) Syntax B) Punctuation C) Portability D) Operators E) Key words

A

This operator increments the value of its operand, then uses the value in context. A) prefix increment B) postfix increment C) prefix decrement D) postfix decrement E) None of these

A

This statement uses the value of a variable or expression to determine where the program will branch to. A) switch B) select C) associative D) scope E) None of these

A

What will the following code display? int number = 6; cout << number++ << endl; A) 6 B) 5 C) 7 D) 0

A

What will the following code display? int number = 6; int x = 0; x = number--; cout << x << endl; A) 6 B) 5 C) 7 D) 0

A

What will the following code display? int numbers[] = {99, 87, 66, 55, 101 }; cout << numbers[3] << endl; A) 55 B) 66 C) 101 D) 87

A

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; } A) 0 1 1 0 B) 0 0 1 0 C) 1 1 0 1 D) 1 0 0 1 E) None of these

A

What will the following segment of code output if the value 11 is entered at the keyboard? int number; cin >> number; if (number > 0) cout << "C++"; else cout << "Soccer"; cout << " is "; cout << "fun" << endl; A) C++ is fun B) Soccer is fun C) C++ D) C++fun E) Soccerfun

A

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; A) 13 B) 18 C) 0 D) unknown

A

When a program lets the user know that an invalid choice has been made, this is known as: A) input validation B) output correction C) compiler criticism D) output validation 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. A) Parentheses B) Exponents C) Calculations D) Coercions E) None of the above

A

When used as parameters, these types of variables allow a function to access the parameter's original argument. A) reference B) floating-point C) counter D) undeclared E) None of these

A

Which is true about the following statement? cout << setw(4) << num4 << " "; A) It allows four spaces for the value in the variable num4. B) It outputs "setw(4)" before the value in the variable num4. C) It should use setw(10) to output the value in the variable num10. D) It inputs up to four characters stored in the variable num4. E) None of these

A

The while loop is this type of loop. A) post-test B) pre-test C) infinite D) limited E) None of these

B

A ________ variable is declared outside all functions. A) local B) global C) floating-point D) counter E) None of these

B

A file must be ________ before data can be written to or read from it. A) closed B) opened C) buffered D) initialized E) None of these

B

A function ________ eliminates the need to place a function definition before all calls to the function. A) header B) prototype C) argument D) parameter E) None of these

B

A set of well-defined steps for performing a task or solving a problem is known as a(n): A) Hierarchy B) Algorithm C) Central Processing Unit D) Encoded instruction E) None of the above

B

A two-dimensional array is like ________ put together. A) an array and a function B) several identical arrays C) two functions D) two arrays of different types E) None of these

B

A variable whose value can be either true or false is of this data type. A) binary B) bool C) T/F D) float E) None of the above

B

A(n) ________ is a diagram that shows the logical flow of a program. A) UML diagram B) flowchart C) hierarchy chart D) program schematic E) None of these

B

A(n) ________ is the most fundamental set of programs on a computer. A) compiler B) operating system C) application D) utility program E) None of these

B

The individual values contained in array are known as ________. A) parts B) elements C) numbers D) constants E) None of these

B

The programmer usually enters source code into a computer using: A) Pseudocode B) A text editor C) A hierarchy chart D) A compiler E) None of the above

B

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: 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

These are operators that add and subtract one from their operands. A) plus and minus B) ++ and -- C) binary and unary D) conditional and relational E) None of these

B

These operators connect two or more relational expressions into one, or reverse the logic of an expression. A) relational B) logical C) irrational D) negation E) None of these

B

These types of arguments are passed to parameters automatically if no argument is provided in the function call. A) Local B) Default C) Global D) Relational E) None of these

B

This is a complete instruction that causes the computer to perform some action. A) Line B) Statement C) Variable D) Key Word E) None of the above

B

This is a dummy function that is called instead of the actual function it represents. A) main function B) stub C) driver D) overloaded function

B

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. A) do-while B) while C) for D) infinite E) None of these

B

This is a variable that is regularly incremented or decremented each time a loop iterates. A) constant B) counter C) control statement D) null terminator E) None of these

B

This step will uncover any syntax errors in your program. A) Editing B) Compiling C) Linking D) Executing E) None of these

B

To access an array element, use the array name and the element's ________. A) data type B) subscript C) name D) value E) None of these

B

To read data from a file, you define an object of this data type. A) inputFile B) ifstream C) fstream D) ofstream

B

What does the following statement do? vector<int> 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.

B

What does the term hardware refer to? A) The relative difficulty of programming B) The physical components that a computer is made of C) The way a computer's storage space is organized D) The logical flow of instructions E) None of the above.

B

What is the output of the following code segment? n = 1; for ( ; n <= 5; ) cout << n << ' '; n++; A) 1 2 3 4 5 B) 1 1 1 ... and on forever C) 2 3 4 5 6 D) 1 2 3 4 E) 2 3 4 5

B

What is the output of the following code segment? n = 1; while (n <= 5) cout << n << ' '; n++; A) 1 2 3 4 5 B) 1 1 1... and on forever C) 2 3 4 5 6 D) 1 2 3 4 E) 2 3 4 5

B

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; } A) 2 2 B) 4 2 C) 2 4 D) 4 4

B

What is the output of the following statement? cout << 4 * (15 / (1 + 3)) << endl; A) 15 B) 12 C) 63 D) 72 E) None of these

B

What is the value of average after the following code executes? double average; average = 1.0 + 2.0 + 3.0 / 3.0; A) 2.0 B) 4.0 C) 1.5 D) 6.0

B

What is the value of the following expression? true && false A) true B) false C) -1 D) +1

B

What is the value stored at x, given the statements: int x; x = 3 / static_cast<int>(4.5 + 6.4); A) .3 B) 0 C) .275229 D) 3.3 E) None of these

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; A) Nothing will be displayed. B) false C) x D) true

B

What will the following code display? int number = 6 int x = 0; x = --number; cout << x << endl; A) 6 B) 5 C) 7 D) 0

B

What will the following code display? int number = 7; cout << "The number is " << "number" << endl; A) The number is 7 B) The number is number C) The number is7 D) The number is 0

B

What will the following code display? int numbers[4] = { 99, 87 }; cout << numbers[3] << endl; A) 87 B) 0 C) garbage D) This code will not compile

B

Whereas < is called a relational operator, x < y is called a(n) ________. A) Arithmetic operator B) Relative operator C) Relational expression D) Largeness test E) None of these

C

A file ________ is a small holding section of memory that file-bound information is first written to. A) name B) number C) buffer D) segment E) None of these

C

Arrays may be ________ at the time they are ________. A) resized, executed B) re-scoped, deleted C) initialized, declared D) pre-compiled, typecast E) None of these

C

The statements written by the programmer are called: A) Syntax B) Object code C) Source code D) Runtime libraries E) None of the above

C

The value in this type of local variable persists between function calls. A) global B) internal C) static D) dynamic E) None of these

C

These are used to declare variables that can hold real numbers. A) Integer data types B) Real data types C) Floating point data types D) Long data types E) None of the above

C

This control sequence is used to skip over to the next horizontal tab stop. A) \n B) \h C) \t D) \a E) \'

C

This is a control structure that causes a statement or group of statements to repeat. A) decision statement B) constant C) loop D) cout object E) None of these

C

This is a variable, usually a bool or an int, that signals when a condition exists. A) relational operator B) arithmetic operator C) flag D) float E) None of these

C

This loop is a good choice when you know how many times you want the loop to iterate in advance of entering the loop. A) do-while B) while C) for D) infinite E) None of these

C

This manipulator causes the field to be left-justified with padding spaces printed to the right. A) left_justify B) right C) left D) left_pad E) None of these

C

This manipulator is used to establish a field width for the value immediately following it. A) field_width B) set_field C) setw D) iomanip E) None of the above

C

This statement causes a function to end. A) end B) terminate C) return D) release E) None of these

C

This statement will pause the screen, until the [Enter] key is pressed. A) cin; B) cin.getline(); C) cin.get(); D) cin.ignore(); E) cin.input();

C

This stream manipulator forces cout to print the digits in fixed-point notation. A) setprecision(2) B) setw(2) C) fixed D) setfixed(2) E) None of these

C

This term refers to the programmer reading the program from the beginning and stepping through each statement. A) Pseudocoding B) Software Engineering C) Desk Checking D) Spot Checking E) None of the above

C

This type of variable is defined inside a function and is not accessible outside the function. A) global B) reference C) local D) counter E) None of these

C

This vector function returns true if the vector has no elements. A) has_no_elements B) null_size C) empty D) is_empty

C

A two-dimensional 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

D

An Integrated Development Environment typically consists of: A) A text editor B) A compiler C) A debugger D) All of the above E) None of the above

D

An example of a secondary storage device is: A) The computer's main memory B) The keyboard C) The monitor D) The disk drive E) None of the above

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; A) 0 B) 1 C) 2 D) —3 E) None of these

D

At the heart of a computer is its central processing unit. The CPU's job is: A) To fetch instructions B) To carry out the operations commanded by the instructions C) To produce some outcome or resultant information D) All of the above E) None of the above

D

For every opening brace in a C++ program, there must be a: A) String literal B) Function C) Variable D) Closing brace E) None of the above

D

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; A) 0 B) 1 C) 2 D) 3 E) None of these

D

If you intend to place a block of statements within an if statement, you must place these around the block. A) Parentheses ( ) B) Square brackets [ ] C) Angle brackets < > D) Curly braces { } E) None of these

D

In C++ 11, if you want an integer literal to be treated as a long long int, you can append ________ at the end of the number. A) L B) <INT> C) I D) LL E) None of the above

D

In the process of translating a source file into an executable file, which of the following is the correct sequence? A) Source code, preprocessor, modified source code, linker, object code, compiler, executable code. B) Preprocessor, source code, compiler, executable code, linker, modified source code, object code. C) Source code, compiler, modified source code, preprocessor, object code, linker, executable code. D) Source code, preprocessor, modified source code, compiler, object code, linker, executable code. E) Source code, linker, object code, compiler, modified source code, preprocessor, executable code.

D

Input values should always be checked for: A) Appropriate range B) Reasonableness C) Division by zero, if division is taking place D) All of these E) None of these

D

Subscript numbering in C++________. 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

What will the following code display? int x = 0; for (int count = 0; count < 3; count++) x += count; cout << x << endl; A) 0 1 2 B) 0 C) 6 D) 3

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; } A) Each element in the array is initialized to 0.0 B) Each element in the array, except the first, 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 program segment display? int funny = 7, serious = 15; funny = serious % 2; if (funny != 1) { funny = 0; serious = 0; } else if (funny == 2) { funny = 10; serious = 10; } else { funny = 1; serious = 1; } cout << funny << " " << serious << endl; A) 7 15 B) 0 0 C) 10 10 D) 1 1 E) None of these

D

What will the value of result be after the following statement executes? result = 6 - 3 * 2 + 7 - 10 / 2 ; A) 8 B) 6 C) 1.5 D) 2

D

When this operator is used with string operands it concatenates them, or joins them together. A) & B) * C) % D) + E) None of the above

D

Which data type typically requires only one byte of storage? A) short B) int C) float D) char E) double

D

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 } A) 4 B) 6 C) 10 D) 15

D

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 } A) 6 B) 8 C) 9 D) 7

D

Which of the following correctly consolidates the following declaration statements into one statement? int x = 7; int y = 16; int z = 28; A) int x = 7; y = 16; z = 28; B) int x = 7 y = 16 z = 28; C) int x, y, z = 7, 16, 28 D) int x = 7, y = 16, z = 28; E) None of these will work.

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

True/False: You may not use the break statement in a nested loop.

FALSE

True/False: The only difference between the get function and the >> operator is that get reads the first character typed, even if it is a space, tab, or the [Enter] key.

TRUE

True/False: The term "bit" stands for binary digit.

TRUE

True/False: The update expression of a for loop can contain more than one statement, e.g. counter++, total+= sales.

TRUE

True/False: When C++ is working with an operator, it strives to convert the operands to the same type.

TRUE

If you leave out the size declarator in an array definition: A) you must furnish 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

A

A for statement contains three expressions: initialization, test, and A) update B) reversal C) null D) validation E) None of these

A

A function ________ contains the statements that make up the function. A) definition B) prototype C) call D) expression E) parameter list

A

A two-dimensional array can be viewed as ________ and ________. A) rows, columns B) arguments, parameters C) increments, decrements D) All of these E) None of these

A

A two-dimensional array can have elements of ________ data type(s). A) one B) two C) four D) Any of these E) None of these

A

An array can store a group of values, but the values must be: A) the same data type B) each of a different data type C) constants D) integers E) None of these

A

An array of string objects that will hold 5 names would be declared using which statement? A) string names[5]; B) string names(5); C) string names5; D) String[5] names; E) None of these will work.

A

During which stage does the central processing unit retrieve from main memory the next instruction in the sequence of program instructions? A) fetch B) decode C) execute D) portability stage

A

Even when there is no power to the computer, data can be held in: A) Secondary storage B) The Input Device C) The Output Device D) The Algorithm E) None of the above

A

This vector function returns the number of elements in a vector. A) size B) num_elements C) elements D) length

A

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; } A) 2 0 2 B) 2 2 2 C) 0 0 0 D) 2 0 0

A

What is the value of cookies after the execution of the following statements? int number = 38, children = 4, cookies; cookies = number % children; A) 2 B) 0 C) 9 D) .5 E) None of these

A

What is the value of donuts after the following code executes? int donuts = 10; if (donuts != 10) donuts = 0; else donuts += 2; A) 12 B) 10 C) 0 D) 2

A

What is the value of the following expression? false || true A) true B) false C) -1 D) +1

A

What is the value of the following expression? true && true A) true B) false C) -1 D) +1

A

What is the value of the following expression? true || true A) true B) false C) -1 D) +1

A

What will the following code display? cout << "Four\n" << "score\n"; cout << "and" << "\nseven"; cout << "\nyears" << " ago" << endl; 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

A

This is used in a program to mark the beginning or ending of a statement, or separate items in a list. A) Separators B) Punctuation C) Operators D) Key Words E) None of the above

B

This is used to mark the end of a complete C++ programming statement. A) Pound Sign B) Semicolon C) Data type D) Void E) None of the above

B

This means to increase a value by one. A) decrement B) increment C) modulus D) parse E) None of these

B

This operator performs a logical NOT operation. A) -- B) ! C) <> D) >< E) None of these

B

This statement causes a loop to terminate early. A) stop B) break C) null D) terminate E) None of these

B

A function can have zero to many parameters, and it can return this many values. A) zero to many B) no C) only one D) a maximum of ten E) None of these

C

A statement that starts with a # symbol is called a: A) Comment B) Function C) Preprocessor directive D) Key word E) None of the above

C

A variable's ________ is the part of the program that has access to the variable. A) data type B) value C) scope D) reach E) None of the above

C

A(n) ________ is a set of instructions that the computer follows to solve a problem. A) Compiler B) Linker C) Program D) Operator E) None of the above

C

A(n) ________ is information that is passed to a function, and a(n) ________ is information that is received by a function. A) function call, function header B) parameter, argument C) argument, parameter D) prototype, header 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

Associativity is either right to left or: A) Top to bottom B) Front to back C) Left to right D) Undeterminable E) None of the above

C

True/False: C++ limits the number of array dimensions to two.

FALSE

What is the modulus operator? A) + B) * C) & D) % E) ||

D

True/False: A function's return data type must be the same as the function's parameter(s).

FALSE

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 } A) 6 B) 8 C) 9 D) 7

A

A variable declaration announces the name of a variable that will be used in a program, as well as: A) The type of data it will be used to hold B) The operators that will be used on it C) The number of times it will be used in the program D) The area of the code in which it will be used E) None of the above

A

A(n) ________ can be used to specify the starting values of an array. A) initialization list B) array name C) subscript D) element E) None of these

A

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; A) 15 B) 10 C) 25 D) 0 E) 5

A

An array can easily be stepped through by using a ________. A) for loop B) reference variable C) named constant D) null value E) None of these

A

Functions are ideal for use in menu-driven programs. When a user selects a menu item, the program can ________ the appropriate function. A) call B) prototype C) define D) declare E) None of these

A

How many elements does the following array have? int bugs[1000]; A) 1000 B) 999 C) 1001 D) Cannot tell from the code

A

How many times will the following loop display "Hello"? for (int i = 0; i < 20; i++) cout << "Hello!" << endl; A) 20 B) 19 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; A) 20 B) 19 C) 21 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. A) persist B) execute C) communicate D) change E) None of these

A

In C++ 11, the ________ tells the compiler to determine the variable's data type from the initialization value. A) auto key word B) #include preprocessor directive C) variable's name D) dynamic_cast key word E) None of the above

A

A function is executed when it is: A) defined B) prototyped C) declared D) called E) None of these

D

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 } A) 4 B) 6 C) 10 D) 15

A

Which of the following is not one of the five major components of a computer system? A) Preprocessor B) The CPU (central processing unit) C) Main memory D) Input/Output device E) Secondary storage device

A

Which statement is equivalent to the following? number += 1; A) number = number + 1; B) number + 1; C) number = 1; D) None of these

A

Without this statement appearing in a switch construct, the program "falls through" all of the statements below the one with the matching case expression. A) break B) exit C) switch D) scope E) None of these

A

An array with no elements is ________. 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

B

An element of a two-dimensional array is referred to by ________ followed by ________. A) the array name, the column number of element B) the row subscript of the element, the column subscript of the element C) a comma, a semicolon D) the row subscript of element, the array name 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? A) name = Jane; B) name = "Jane"; C) name = 'Jane'; D) name = (Jane);

B

Besides decimal, two other number systems you might encounter in C++ programs are: A) Octal and Fractal B) Hexadecimal and Octal C) Unary and Quaternary D) Base 7 and Base 9 E) None of the above

B

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? A) fetch B) decode C) execute D) portability stage

B

EXIT_FAILURE and ________ are named constants that may be used to indicate success or failure when the exit() function is called. A) EXIT_TERMINATE B) EXIT_SUCCESS C) EXIT_OK D) RETURN_OK E) None of these

B

Every complete C++ program must have a ________. A) comment B) function named main C) preprocessor directive D) symbolic constant E) cout statement

B

Given that, x = 2, y = 1, and z = 0, what will the following cout statement display? cout << "answer = " << (x || !y && z) << endl; A) answer = 0 B) answer = 1 C) answer = 2 D) 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? int x = 1; int y = 2; int z = 3; calc(x, y); cout << x << " " << y << " " << z << endl; A) 1 2 3 B) 1 6 3 C) 3 6 3 D) 1 14 9 E) None of these

B

Here is the header for a function named computeValue: void computeValue(int value) Which of the following is a valid call to the function? A) computeValue(10) B) computeValue(10); C) void computeValue(10); D) void computeValue(int x);

B

How many times will the following loop display "Hello"? for (int i = 1; i < 20; i++) cout << "Hello!" << endl; A) 20 B) 19 C) 21 D) An infinite number of times

B

If a function does not have a prototype, default arguments may be specified in the function ________. A) call B) header C) execution D) return type E) None of these

B

If you place a semicolon after the statement: if (x < y) A) The code will not compile. B) The compiler will interpret the semicolon as a null statement. C) The if statement will always evaluate to false. D) All of the above E) None of these

B

If you use a C++ key word as an identifier, your program will: A) Execute with unpredictable results B) not compile C) understand the difference and run without problems D) Compile, link, but not execute E) None of the above

B

If you want a user to enter exactly 20 values, which loop would be the best to use? A) do-while B) for C) while D) infinite E) None of these

B

In C++ the = operator indicates: A) equality B) assignment C) subtraction D) negation E) None of these

B

In a C++ program, two slash marks ( // ) indicate: A) The end of a statement B) The beginning of a comment C) The end of the program D) The beginning of a block of code E) None of the above

B

In any program that uses the cin object, you must include the ________. A) compiler B) iostream header file C) linker D) >> and << operators E) None of the above

B

In the following C++ statement, what will be executed first according to the order of precedence? result = 6 - 3 * 2 + 7 - 10 / 2 ; A) 6 - 3 B) 3 * 2 C) 2 + 7 D) 7 - 10 E) 10 / 2

B

It is ________ to pass an argument to a function that contains 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

B

It is a good programming practice to ________ your functions by writing comments that describe what they do. A) execute B) document C) eliminate D) prototype E) None of these

B

Look at the following function prototype. int myFunction(double); What is the data type of the function's parameter variable? A) int B) double C) void D) Can't tell from the prototype

B

Look at the following statement. while (x++ < 10) Which operator is used first? A) ++ B) < C) Neither. The expression is invalid.

B

Mistakes that cause a running program to produce incorrect results are called: A) Syntax errors B) Logic errors C) Compiler errors D) Linker errors E) None of the above

B

Programmer-defined names of memory locations that may hold data are: A) Operators B) Variables C) Syntax D) Operands E) None of the above

B

Something within a while loop must eventually cause the condition to become false, or a(n) ________ results. A) null value B) infinite loop C) unexpected exit D) compiler error E) None of these

B

The ________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed. A) Output stream B) cin object C) cout object D) Preprocessor E) None of the above

B

The do-while loop is considered a(n) ________ loop. A) pre-test B) post-test C) infinite D) limited E) None of these

B

The function, pow(x, 5.0), requires this header file. A) cstdlib B) cmath C) cstring D) iostream E) iomanip

B

True/False: One reason for using functions is to break programs into manageable units, or modules.

TRUE

What will the following loop display? int x = 0; while (x < 5) { cout << x << endl; x++; } 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 value of x be after the following statements execute? int x; x = 18 / 4; A) 4.5 B) 4 C) 0 D) unknown

B

What will the value of x be after the following statements execute? int x; x = 18.0 / 4; A) 4.5 B) 4 C) 0 D) unknown

B

When a relational expression is false, it has the value ________. A) one B) zero C) zero, one, or minus one D) less than zero E) None of these

B

When a variable is assigned a number that is too large for its data type, it: A) underflows B) overflows C) reverses polarity D) exceeds expectations E) None of the above

B

When the increment operator precedes its operand, as in ++num1, the expression is in this mode. A) postfix B) prefix C) preliminary D) binary E) None of these

B

When using the sqrt function you must include this header file. A) cstdlib B) cmath C) cstring D) iostream E) iomanip

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 element values E) None of these

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 } A) 6 B) 8 C) 10 D) 9

B

Which of the following best describes an operator? A) An operator is a rule that must be followed when constructing a program. B) An operator allows you to perform operations on one or more pieces of data. 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 word that has a special meaning. E) An operator is a symbolic name that refers to a variable.

B

Which of the following defines a double-precision floating point variable named payCheck? A) float payCheck; B) double payCheck; C) payCheck double; D) Double payCheck;

B

Which one of the following would be an illegal variable name? A) dayOfWeek B) 3dGraph C) _employee_num D) June1997 E) itemsorderedforthemonth

B

Which statement is equivalent to the following? x = x * 2; A) x * 2; B) x *= 2; C) x = x * x; D) None of these

B

You can use these to override the rules of operator precedence in a mathematical expression. A) [Brackets] B) (Parentheses) C) {Braces} D) The escape character \ E) None of these

B

You must have a ________ for every variable you intend to use in a program. A) purpose B) definition C) comment D) constant E) None of the above

B

You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written? A) cin << length, width, height; B) cin.get(length, width, height); C) cin >> length >> width >> height; D) cin >> length, width, height; E) cin << length; width; height;

B

________ functions may have the same name, as long as their parameter lists are different. A) Only two B) Two or more C) Zero D) Un-prototyped E) None of these

B

________ must be included in any program that uses the cout object. A) Opening and closing braces B) The header file iostream C) Comments D) Escape sequences E) None of the above

B

________ reads a line of input, including leading and embedded spaces, and stores it in a string object. A) cin.get B) getline C) cin.getline D) get E) None of these

B

________ represent storage locations in the computer's memory. A) Literals B) Variables C) Comments D) Integers E) None of the above

B

Assume that a program has the following variable definition: char letter; Which of the following statements correctly assigns the character Z to the variable? A) letter = Z; B) letter = "Z"; C) letter = 'Z'; D) letter = (Z);

C

Assuming dataFile is a file stream object, the statement: dataFile.close(); 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

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? A) write(outFile, number); B) outFile >> number; C) outFile << number; D) number >> outFile;

C

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) A) 3, 4, 6, 7 are false. B) Only 5 is false. C) 3 and 4 are false. D) All are false. E) None of these.

C

Assuming you are using a system with 1-byte characters, how many bytes of memory will the following string literal occupy? "William" A) 7 B) 14 C) 8 D) 1

C

By using the same ________ you can build relationships between data stored in two or more arrays. A) array name B) data C) subscript D) arguments E) None of these

C

Character constants in C++ are always enclosed in ________. A) [brackets] B) "double quotation marks" C) 'single quotation marks' D) {braces} E) (parentheses)

C

Characters or symbols that perform operations on one or more operands are: A) Syntax B) Op codes C) Operators D) Program ops E) None of the above

C

Computer programs are also known as: A) hardware B) firmware C) software D) silverware E) None of the above

C

Given the following declaration, where is the value 77 stored in the scores array? int scores[] = {83, 62, 77, 97}; A) scores[0] B) scores[1] C) scores[2] D) scores[4]

C

How many times will the following loop display "Hello"? for (int i = 0; i <= 20; i++) cout << "Hello!" << endl; A) 20 B) 19 C) 21 D) An infinite number of times

C

If you place a semicolon after the test expression in a while loop, it is assumed to be a(n): A) pre-test loop B) post-test loop C) null statement D) infinite loop E) None of these

C

In a broad sense, the two primary categories of programming languages are: A) Mainframe and PC B) Hardware and Software C) Low-level and High-level D) COBOL and BASIC E) None of the above

C

In memory, C++ automatically places a ________ at the end of string literals. A) Semicolon B) Quotation marks C) Null terminator D) Newline escape sequence E) None of the above

C

Internally, the CPU consists of two parts: A) The Output Device and the Input Device B) The Software and the Hardware C) The Control Unit and the Arithmetic and Logic Unit D) The Single-task Device and the Multi-task Device E) None of the above

C

Look at the following function prototype. int myFunction(double, double, double); How many parameter variables does this function have? A) 1 B) 2 C) 3 D) Can't tell from the prototype

C

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? A) 13 and 14 B) 8 and 9 C) 14 D) 13 E) 15

C

Relational operators allow you to ________ numbers. A) add B) multiply C) compare D) average E) None of these

C

The ________ is/are used to display information on the computer's screen. A) Opening and closing braces B) Opening and closing quotation marks C) cout object D) Backslash E) None of the above

C

The ________ of a variable is limited to the block in which it is declared. A) precedence B) associativity C) scope D) branching ability E) None of these

C

The ________ operator always follows the cin object, and the ________ operator follows the cout object. A) binary, unary B) conditional, binary C) >>, << D) <<, >> E) None of the above

C

The computer's main memory is commonly known as: A) The hard disk B) The floppy disk C) RAM D) Secondary storage E) None of the above

C

The default section of a switch statement performs a similar task as the ________ portion of an if/else if statement. A) conditional B) break C) trailing else D) All of these E) None of these

C

The numeric data types in C++ can be broken into two general categories: A) numbers and characters B) singles and doubles C) integer and floating point D) real and unreal E) None of the above

C

The programming process consists of several steps, which include: A) Input, Processing, and Output B) Key Words, Operators, and Punctuation C) Design, Creation, Testing, and Debugging D) Syntax, Logic, and Error Handling E) None of the above

C

Three primary activities of a program are: A) Variables, Operators, and Key Words B) Lines, Statements, and Punctuation C) Input, Processing, and Output D) Integer, Floating-point and Character E) None of the above

C

To allow file access in a program, you must #include this header file. A) file B) fileaccess C) fstream D) cfile

C

To assign the contents of one array to another, you must use ________. A) the assignment operator with the array names B) the equality 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. A) contents B) size, expressed as an integer C) name D) value of the first element E) None of these

C

Unlike regular variables, these can hold multiple values. A) constants B) named constants C) arrays D) floating-point variables E) None of these

C

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; } A) 5 B) 2 C) 7 D) "getValue(x)"

C

What is the output of the following segment of code if the value 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; A) 0 B) 3 C) 13 D) 28 E) None of these

C

What is the value of donuts after the following code executes? int donuts = 10; if (donuts = 1) donuts = 0; else donuts += 2; A) 12 B) 10 C) 0 D) 1

C

What is the value of number after the following statements execute? int number = 10; number += 5; number -= 2; number *= 3; A) 3 B) 30 C) 15 D) 2

C

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; A) 10 B) 120 C) 20 D) This code will not compile.

C

What will the following C++ 11 code display? vector<int> numbers { 3, 5 }; for (int val : numbers) cout << val << endl; A) 5 5 5 B) 3 3 3 3 3 C) 3 5 D) Nothing. This code has an error.

C

What will the following code display? cout << "Four " << "score "; cout << "and " << "seven/n"; cout << "years" << "ago" << endl; A) Four score and seven yearsago B) Four score and seven years ago C) Four score and seven/nyearsago D) Four score and seven yearsago

C

What will the following code display? cout << "Monday"; cout << "Tuesday"; cout << "Wednesday"; A) Monday Tuesday Wednesday B) Monday Tuesday Wednesday C) MondayTuesdayWednesday D) "Monday" "Tuesday" "Wednesday"

C

What will the following code display? int number = 6; cout << ++number << endl; A) 6 B) 5 C) 7 D) 0

C

What will the following code display? int number = 6; ++number; cout << number << endl; A) 6 B) 5 C) 7 D) 0

C

What will the following code display? int number = 6; number++; cout << number << endl; A) 6 B) 5 C) 7 D) 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; A) 99 87 66 55 101 B) 87 66 55 101 C) 87 66 55 D) Nothing. This code has an error.

C

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; A) This is a test question! B) Congratulations! That's a high score! This is a test question! C) That's a high score! This is a test question! D) Congratulations! That's a high score! E) None of these

C

What will the following segment of code output? 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!"; A) You failed the test! B) You passed the test! C) You failed the test! You passed the test! D) You failed the test! You did poorly on the test! E) None of the above

C

What will the value of x be after the following statements execute? int x; x = 18 % 4; A) 0.45 B) 4 C) 2 D) unknown

C

When an if statement is placed within the conditionally-executed code of another if statement, this is known as: A) complexity B) overloading C) nesting D) validation E) None of these

C

When the final value of an expression is assigned to a variable, it will be converted to: A) The smallest C++ data type B) The largest C++ data type C) The data type of the variable D) The data type of the expression E) None of the above

C

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 } A) 4 B) 6 C) 10 D) 15

C

Which of the following expressions will determine whether x is less than or equal to y? A) x > y B) x =< y C) x <= y D) x >= y

C

Which of the following statements about global variables is true? A) A global variable is accessible only to the main function. B) A global variable is declared in the highest-level block in which it is used. 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

A loop that is inside another loop is called: A) an infinite loop B) a pre-test loop C) a post-test loop D) a nested loop E) None of these

D

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? 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

Which statement correctly uses C++ 11 to initialize a vector of ints named n with the values 10 and 20? A) vector n<int>(10, 20); B) vector<int> n = {10, 20}; C) vector<int> n { 10, 20 }; D) int vector n ({10}, {20});

C

Which statement will read an entire line of input into the following string object? string address; A) cin << address; B) cin address; C) getline(cin, address); D) cin.get(address); E) None of the above

C

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"; A) 100 B) 10 C) 99 D) 0 E) All of these

C

Words that have a special meaning and may be used only for their intended purpose are known as: A) Operators B) Programmer Defined Words C) Key Words D) Syntax E) None of the above

C

You may define a ________ in the initialization expression of a for loop. A) constant B) function C) variable D) new data type E) None of these

C

________ are used to translate each source code instruction into the appropriate machine language instruction. A) Modules B) Library routines C) Compilers D) Preprocessor directives E) None of the above

C

5) 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

D

This vector function removes an item from a vector. A) remove_item B) delete_item C) erase D) pop_back

D

What is the output of the following code segment? int x = 5; if (x = 2) cout << "This is true!" << endl; else cout << "This is false!" << endl; cout << "This is all folks!" << endl; A) This is true! B) This is false! C) This is true! This is false! D) This is true! This is all folks! E) None of these

D

A ________ argument is passed to a parameter when the actual argument is left out of the function call. A) false B) true C) null D) default E) None of these

D

A character literal is enclosed in ________ quotation marks, whereas a string literal is enclosed in ________ quotation marks. A) double, single B) triple, double C) open, closed D) single, double E) None of the above

D

The ________ causes the contents of another file to be inserted into a program. A) Backslash B) Pound sign C) Semicolon D) #include directive E) None of the above

D

The ________ decodes an instruction and generates electrical signals. A) Arithmetic and Logic Unit B) Main memory C) BIOS D) Control Unit E) None of the above

D

The ________ is automatically appended to a character array when it is initialized with a string constant. A) array name B) number of elements C) value of the first element D) null terminator E) None of these

D

The first step in using the string class is to #include the ________ header file. A) iostream B) cctype C) cmath D) string E) None of the above

D

The name for a memory location that may hold data is: A) Key Word B) Syntax C) Operator D) Variable E) None of the above

D

The range-based for loop, in C++ 11, is designed to work with a built-in variable known as the ________. A) counter variable B) i variable C) iterator D) range variable E) None of these

D

The total number of digits that appear before and after the decimal point is sometimes referred to as: A) floating points B) significant digits C) precision D) B and C E) None of these

D

The value in a ________ variable persists between function calls. A) dynamic B) local C) counter D) static local

D

This function causes a program to terminate, regardless of which function or control mechanism is executing. A) terminate() B) return() C) continue() D) exit() E) None of these

D

This is a special value that marks the end of a list of values. A) constant B) variable C) loop D) sentinel E) None of these

D

This is a statement that causes a function to execute. A) for loop B) do-while loop C) function prototype D) function call E) None of these

D

This may be used to write information to a file. A) cout object B) pen object C) output object D) stream insertion operator E) None of these

D

This operator is known as the logical OR operator. A) -- B) // C) # D) || E) None of these

D

This operator is used in C++ to represent equality. A) = B) >< C) !! D) == E) None of these

D

This operator takes an operand and reverses its truth or falsehood. A) || B) relational C) arithmetic D) ! E) None of these

D

This statement may be used to stop a loop's current iteration and begin the next one. A) break B) terminate C) re-iterate D) continue E) None of these

D

This statement may be used to stop a loop's current iteration and begin the next one. A) break B) terminate C) return D) continue 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

D

To use the rand() function, you must #include this header file in your program. A) iostream B) iomanip C) iorand D) cstdlib E) None of these

D

To write data to a file, you define an object of this data type. A) outputFile B) ifstream C) fstream D) ofstream

D

What does the following statement do? vector<int> v(10, 2); It creates a vector object and initializes all the first two elements with the values 10 and 2. It creates a vector object with a starting size of 2 and the first element initialized with the value 10. It creates a vector object with a starting size of 10 and the first element initialized with the value 2. It creates a vector object with a starting size of 10 and all elements are initialized with the value 2.

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; A) 10 B) 7 C) The string "x >= y" D) 1 E) 0

D

What is the last legal subscript that can be used with the following array? int values[5]; A) 0 B) 5 C) 6 D) 4

D

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; } A) 98 B) 99 C) 0 D) 1

D

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; } A) 2 0 2 B) 2 2 2 C) 0 0 0 D) 2 0 0

D

What statement best describes a variable and its primary purpose? A) A variable is a structured, general-purpose language designed primarily for teaching programming. B) A variable is a collection of eight bits. C) A variable is a word that has a special meaning to the compiler. 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 "line" of code in the body of a program, which may change.

D

What will the following code display? cout << "Four" << "score" << endl; cout << "and" << "seven" << endl; cout << "years" << "ago" << endl; A) Four score and seven years ago B) Four score and seven years ago C) Fourscoreandsevenyearsago D) Fourscore andseven yearsago

D

What will the following code display? int x = 0, y = 1, z = 2; cout << x << y << z << endl; A) 0 1 2 B) 0 1 2 C) xyz D) 012

D

In a function header, you must furnish: A) data type(s) of the parameters B) data type of the return value C) the name of function D) names of parameter variables E) All of these

E

Of the following, which is a valid C++ identifier? A) June1997 B) _employee_number C) ___department D) myExtraLongVariableName E) All of the above are valid identifiers.

E

This function in C++ allows you to identify how many bytes of storage on your computer system an integer data value requires. A) len B) bytes C) f(x) D) int E) sizeof

E

Which escape sequence causes the cursor to move to the beginning of the current line? A) \n B) \t C) \a D) \b E) \r

E

Which of the following is a common input device? A) Keyboard B) Mouse C) Scanner D) Microphone E) All of the above

E

True/False: C++ 11 introduces an alternative way to define variables, using the template key word and an initialization value.

FALSE

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

FALSE

True/False: If you do not follow a consistent programming style, your programs will generate compiler errors.

FALSE

True/False: If you want to know the length of the string that is stored in a string object, you can call the object's size member function.

FALSE

True/False: In C++ 11, the range-based for loop is best used in situations where you need the element subscript for some purpose.

FALSE

True/False: In C++, it is impossible to display the number 34.789 in a field of 9 spaces with 2 decimal places of precision.

FALSE

True/False: In programming, the terms "line" and "statement" always mean the same thing.

FALSE

True/False: Local variables are initialized to zero by default.

FALSE

True/False: Machine language is an example of a high-level language.

FALSE

True/False: Programs are commonly referred to as hardware.

FALSE

True/False: Pseudocode is a form of program statement that will always evaluate to "false."

FALSE

True/False: The C++ language requires that you give variables names that indicate what the variables are used for.

FALSE

True/False: The condition that is tested by a while loop must be enclosed in parentheses and terminated with a semicolon.

FALSE

True/False: The default section is required in a switch statement.

FALSE

True/False: The fixed manipulator causes a number to be displayed in scientific notation.

FALSE

True/False: If the sub-expression on the left side of the || operator is true, the expression on the right side will not be checked.

TRUE

True/False: A CPU really only understands instructions that are written in machine language.

TRUE

True/False: A parameter is a special-purpose variable that is declared inside the parentheses of a function definition.

TRUE

True/False: A preprocessor directive does not require a semicolon at the end.

TRUE

True/False: A static variable that is defined within a function is initialized only once, the first time the function is called.

TRUE

True/False: A vector object automatically expands in size to accommodate the items stored in it.

TRUE

True/False: A while loop's body can contain multiple statements, as long as they are enclosed in braces.

TRUE

True/False: An expression that has any value other than 0 is considered true by an if statement.

TRUE

True/False: An individual array element can be processed like any other type of C++ variable.

TRUE

True/False: An initialization expression may be omitted from the for loop if no initialization is required.

TRUE

True/False: An output file is a file that data is written to.

TRUE

True/False: As a rule of style, when writing an if statement you should indent the conditionally-executed statements.

TRUE

True/False: Both of the following if statements perform the same operation. if (sales > 10000) commissionRate = 0.15; if (sales > 10000) commissionRate = 0.15;

TRUE

True/False: C++ does not have a built in data type for storing strings of characters.

TRUE

True/False: Each individual element of an array can be accessed by the array name and an element number, called a subscript.

TRUE

True/False: Escape sequences are always stored internally as a single character.

TRUE

True/False: Floating point constants are normally stored in memory as doubles.

TRUE

True/False: Global variables are initialized to zero by default.

TRUE

True/False: If an array is partially initialized, the uninitialized elements will be set to zero.

TRUE

True/False: If the sub-expression on the left side of an && operator is false, the expression on the right side will not be checked.

TRUE

True/False: If you want to stop a loop before it goes through all its iterations, the break statement may be used.

TRUE

True/False: In C++ 11 you can pass a string object as argument to a file stream object's open member function.

TRUE

True/False: In C++ 11, you cannot use a range-based for loop to modify the contents of an array unless you declare the range variable as a reference.

TRUE

True/False: In C++, key words are written in all lowercase letters.

TRUE

True/False: It is not considered good programming practice to declare all of your variables globally.

TRUE

True/False: It is possible for a function to have some parameters with default arguments and some without.

TRUE

True/False: It is possible to define a file stream object and open a file in one statement.

TRUE

True/False: Multiple relational expressions cannot be placed into the test condition of a for loop.

TRUE


Related study sets

CSC-325: Quiz 8 Review Questions

View Set

Varcarolis: Chapter 13 - Bipolar and Related Disorders

View Set

Windows Command Line (examcomppass)

View Set

Jewish and Early Christian Art (AoW Midterm II)

View Set

6th Grade SS Chapter 30 Alexander the Great and his Empire

View Set