elet 160
true
A static variable that is defined within a function is initialized only once, the first time it is called
true
An initialization expression may be omitted from the for loop if no initialization is required.
false
C++ 11 introduced an alternative way to define variables, using the template key word and an initialization value.
false
The increment and decrement operators can be used in mathematical expressions; however, they cannot be used in relational expressions.
true
Multiple relational expressions cannot be placed into the test condition of a for loop.
infinite loop
Something within a while loop must eventually cause the condition to become false or a(n) ________ results.
4.0
What is the value of average after the following code executes?double average;average = 1.0 + 2.0 + 3.0 / 3.0;
the number is number
What will the following code display?int number = 23;cout << "The number is " << "number" << endl;
for
If you want a user to enter exactly 20 values, which loop would be the best to use?
while
The ________ loop is a good choice when you do not want the loop to iterate if the condition is FALSE in the beginning.
for
The ________ loop is a good choice when you know how many times you want the loop to iterate in advance of entering the loop.
do while
The ________ loop is ideal in situations where you want the loop to iterate at least once.
number *= 2;
Which statement is equivalent to the following?number = number * 2;
number= number +1
number += 1;
default
A ________ argument is passed to a parameter when the actual argument is left out of the function.
global
A ________ variable is declared outside all functions.
opened
A file must be ________ before data can be written to or read from it.
only one
A function can have no parameters, one parameter, or many parameters and can return ________ value(s).
false
A function's return data type must be the same as the function's parameters.
true
A parameter is a special purpose variable that is declared inside the parentheses of a function definition.
True
A value is stored in a variable with an assignment statement.
counter
A variable that is regularly incremented or decremented each time a loop iterates is a
false
A while loop is somewhat limited because the counter can only be incremented by one each time through the loop.
true
A while loop's body can contain multiple statements, as long as they are enclosed in braces.
false
After the following code executes, what is the output if user enters 0?int x = -1;cout << "Enter a 0 or 1: ";cin >> x;if (c)cout << "true" << endl;elsecout << "false" << endl;
true
An output file is a file that data is written to. True
false
Arithmetic operators that share the same precedence have right to left associativity.
closes a file
Assuming dataFile is a file stream object, the following statement:dataFile.close();
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?
false
Because C++ is case-sensitive, all programs must have a function called main or Main
computeValue (10);
Given the following header for a function named computeValue, which of the following is a valid call to the function?void computeValue(int value)
21
How many times will the following loop display "Looping again!"?for (int i = 0; i <= 20; i++)cout << "Looping again!" << endl;
persist
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.
the compiler will interpret the semicolon as a null statement
If you place a semicolon after the statement:if (x < y)
false
In C++, it is impossible to display the number 34.789 in a field of 9 spaces with 2 decimal places of precision.
LL
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.
initialization
In a for statement, this expression is executed only once:
intitialization
In a for statement, this expression is executed only once:
string literal
In the following statement, the characters Hello! are a(n)cout << "Hello!";
true
It is not considered good programming practice to declare all your variables globally.
true
It is possible to define a file stream object and open a file in one statement.
false
Local variables are initialized to zero by default.
True
The cin << statement will stop reading input when it encounters a newline character.
a post test loop
The do-while loop is considered
false
The fixed manipulator causes a number to be displayed in scientific notation.
false
The following code correctly determines whether x contains a value in the range of 0 through 100, inclusive.if (x > 0 && <= 100)
false
The following statement will output $5.00 to the screen:cout << setprecision(5) << dollars << endl;
cmath
The function pow(x, y), requires which header file?
True
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
The preprocessor reads a program before it is compiled and only executes those lines beginning with # symbol.
true
The scope of a variable declared in a for loop's initialization expression always extends beyond the body of the loop.
true
The value of result in the following expression will be 0 if x has the value of 12.result = x > 100 ? 0 : 1;
left
This manipulator causes the field to be left justified with padding spaces printed to the right:
increment
This means to increase a value:
||
This operator represents the logical OR:
#include fstream
To allow file access in a program, you must use ________ in the header file
cstdlib
To use the rand()function, you must include the ________ header file?
ofstream
To write data to a file, you define an object of the ________ data type.
ifstream
To write read data from a file, you define an object of the ________ data type.
13
What is the value of x after the following code executes?int x = 0;int y = 5;int z = 4;x = x + y + z * 2;
Your choice is 1
What will be the output after the following lines of code execute?bool choice;choice = true;cout << "Your choice is " << choice << endl;
7
What will the following code display?#includeusing namespace std;int getValue(int);int main(){int x = 2;cout << getValue(x) << endl;return 0;}int getValue(int num){return num + 5;}
4 2
What will the following code display?#includeusing 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;}
7
What will the following code display?int number = 6;cout << ++number << endl;
0 1 2 3 4
What will the following code display?int x = 0;while (x < 5){cout << x << " ";x++;}
line 3
Which line in the following program contains the prototype showDub function?1 #include2 using namespace std;3 void showDub(int);4 int main()5 {6 int x = 2;7 showDub(x);8 cout << x << endl;9 return 0;10 }11 void showDub(int num)12 {13 cout << (num * 2) << endl;14 }
line 7
Which line in the following program will cause a compiler error?1 #include2 using namespace std;34 int main()5 {6 const int MY_VAL = 77;7 MY_VAL = 99;8 cout << MY_VAL << endl;9 return 0;10 }
double payCheck;
Which of the following defines a double-precision floating-point variable named payCheck?
round(x)
Which of the following functions will return the value of x, rounded to the nearest whole number?
letter = 'M';
Which of the following statements correctly assigns the character M to the variable named letter?
cin.get()
Which of the following statements will pause the screen until the [Enter] key is pressed?
variable
You may define a ________ in the initialization expression of a for loop.
false
You may nest while and do-while loops but you may not nest for loops.
false
You may not use both break and continue statements within the same set of nested loops.
false
You may not use the break statement in a nested loop.
true
You may use the exit() function to terminate a program, regardless of which control mechanism is executing.
false
You must always furnish an argument with a function call.
true
string objects have a member function named c_str that returns the contents of the object formatted as a null-terminated C-string.
pre test
the while loop is a ______ loop