Question | Answer |
Given that x = 2, y = 1, and z = 0, what will the following cout statement display?
cout << "answer =" << (x || !y &&z) <<endl; | answer=1 |
If the sub-expression on the left side of the || operator is true, the expression on the right side will not be checked. | true |
If you place a semicolon after the statement
if (x < y) | the compiler will interpret the semicolon as a null statement |
In C++ the = operator indicates: | assignment |
The default section of a switch statement performs a similar task as the ________ portion of an if/else if statement. | trailing else |
The following code correctly determines whether x contains a value in the range of 0 through 100.
if (x >= 0 && <= 100) | false |
When an if statement is placed within the conditionally-executed code of another if statement, this is known as: | nesting |
What is the value of the following expression?
true && true | false |
Which of the following expressions will determine whether x is less than or equal to y? | x <= y |
Without this statement appearing in a switch construct, the program "falls through" all of the statements below the one with the matching case expression. | break |
You should be careful when using the equality operator to compare floating point values because of potential round-off errors. | true |
When a program lets the user know that an invalid choice has been made, this is known as: | input invalidation |
When a relational expression is false, it has the value ________. | zero |
Input values should always be checked for: | appropriate range
reasonableness
division by zero, if division is taking place |
Both of the following if statements perform the same operation.
if (sales > 10000)
commissionRate = 0.15;
if (sales > 10000) commissionRate = 0.15; | true |
As a rule of style, when writing an if statement you should indent the conditionally-executed statements. | true |
when using the equality operator to compare integer values there will be potential round-off errors. | false |
variables need to be declared before they can be used | false |
when using the equality operator to compare integer values there will be potential round-off errors. | false |
variables need to be declared before they can be used | false |
A statement that starts with a # is called a comment | false |
The following code correctly determines whether x contains a value out of the range of 0 through 100.
if (x < 0 || x> 100) | true |
An example of a secondary storage device is a hard drive | true |
Floating point constants are normally stored in memory as doubles | true |
The following code correctly determines whether x contains a value out of the range of 0 through 100.
if (x < 0 || x> 100) | true |
An example of a secondary storage device is a hard drive | true |
_____________ represent storage locations in the computer's memory | variable |
If you use a C++ key word as an identifier, your program will compile, link, but not execute. | false |
Which of the following is not one of the five major components of a computer system? | preprocessor |
If you use a C++ key word as an identifier, your program will compile, link, but not execute. | false |
A file must be ________ before data can be written to or read from it. | opened |
Which of the following is not one of the five major components of a computer system? | preprocessor |
A file must be ________ before data can be written to or read from it. | opened |
A loop that is inside another loop is called: | a nested loop |
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? | outfile << number; |
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? | outfile << number; |
when using the equality operator to compare integer values there will be potential round-off errors. | false |
Look at the following statement. while (x ++ < 10) what will be executed first? | < |
variables need to be declared before they can be used | false |
If you want a user to enter exactly 20 values, which loop would be the best to use? | for |
A statement that starts with a # is called a comment | false |
In a for statement, this expression is executed only once. | intialization |
Floating point constants are normally stored in memory as doubles | true |
The do-while loop is considered a(n) ________ loop. | post-test |
If you want a user to enter exactly 20 values, which loop would be the best to use? | for |
The scope of a variable declared in a for loop's initialization expression always extends beyond the body of the loop. | false |
The following code correctly determines whether x contains a value out of the range of 0 through 100.
if (x < 0 || x> 100) | true |
An example of a secondary storage device is a hard drive | true |
_____________ represent storage locations in the computer's memory | variable |
This statement may be used to stop a loop's current iteration and begin the next one. | continue |
If you use a C++ key word as an identifier, your program will compile, link, but not execute. | false |
You may nest while and do-while loops, but you may not nest for loops. | false |
Which of the following is not one of the five major components of a computer system? | preprocessor |
A file must be ________ before data can be written to or read from it. | opened |
This statement may be used to stop a loop's current iteration and begin the next one. | continue |
A loop that is inside another loop is called: | a nested loop |
You may nest while and do-while loops, but you may not nest for loops. | false |
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? | outfile << number; |
Look at the following statement. while (x ++ < 10) what will be executed first? | < |
In a for statement, this expression is executed only once. | intialization |
If you want a user to enter exactly 20 values, which loop would be the best to use? | for |
The scope of a variable declared in a for loop's initialization expression always extends beyond the body of the loop. | false |
The do-while loop is considered a(n) ________ loop. | post-test |
The while loop has two important parts: an expression that is tested for a true or false value, and: | a statement or block that is repeated as long as the expression is true |
This loop is a good choice when you know how many times you want the loop to iterate in advance of entering the loop. | for |
This statement causes a loop to terminate early. | break |
This statement may be used to stop a loop's current iteration and begin the next one. | continue |
You may nest while and do-while loops, but you may not nest for loops. | false |
You may not use the break and continue statements within the same set of nested loops. | false |
A ________ variable is declared outside all functions. | global |
A function ________ contains the statements that make up the function. | defnition |
A local variable and a global variable may not have the same name within the same program. | false |
Functions are ideal for use in menu-driven programs. When a user selects a menu item, the program can ________ the appropriate function. | call |
If a function does not have a prototype, default arguments may be specified in the function ________. | header |
In a function header, you must furnish: | data type(s) of the parameters
data type of the return value
the name of function
names of parameter variables |
Local variables are initialized to zero by default. | false |
Look at the following function prototype.
int myFunction(double);
What is the data type of the function's parameter variable? | double |
It is not considered good programming practice to declare all of your variables globally. | true |
You may use the exit( ) function to terminate a program, regardless of which control mechanism is executing. | true |
This is a collection of statements that performs a specific task | function |
One reason for using functions is to break programs into manageable units, or modules. | true |
The value in a(n) ________ variable persists between function calls. | static local |
The value in this type of local variable persists between function calls. | static |
These types of arguments are passed to parameters automatically if no argument is provided in the function call. | default |
When a function is called, flow of control moves to the function's prototype. | false |
You must furnish an argument with a function call. | false |
Unlike regular variables, these can hold multiple values. | array |
To access an array element, use the array name and the element's: | subscript |
By using the same ________ you can build relationships between data stored in two or more arrays | subscripts |
A two-dimensional array can be viewed as ________ and ________. | rows, columns |
An array can store a group of values, but the values must be: | the same data type |
Subscript numbering in C++ | begins with 0 |
Arrays may be ________ at the time they are ________. | initialized, declared |
Given the following declaration, where is 77 stored in the scores array?
int scores[ ]={83, 62, 77, 97}; | scores [2] |
An array can easily be stepped through by using a: | for loop |
To pass an array as an argument to a function, pass the ________ of the array. | name |
A(n) ________ can be used to specify the starting values of an array. | initialization list |
The ________ is automatically appended to a character array when it is initialized with a string constant. | null terminator |
An array of string objects that will hold 5 names would be declared using which statement? | string names[5]; |
It is ________ to pass an argument to a function that contains an individual array element, such as numbers[3]. | legal in C++ |
What will the following code display?
int numbers[ ] = {99, 87, 66, 55, 101 };
cout << numbers[3] << endl; | 55 |
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 |
When you pass an array as an argument to a function, the function can modify the contents of the array. | true |
If an array is partially initialized, the uninitialized elements will be set to zero. | true |
Each individual element of an array can be accessed by the array name and an element number, called a subscript | true |
An individual array element can be processed like any other type of C++ variable. | true |