COP1334 C++ Midterm (Ch. 3) – Flashcards

Unlock all answers in this set

Unlock answers
question
+
answer
When this operator is used with string operands it concatenates them, or joins them together.
question
data type of the variable
answer
When the final value of an expression is assigned to a variable, it will be converted to:
question
left to right
answer
Associativity is either right to left or
question
Ten
answer
The statement cin >> setw(10) >> str; will read up to this many characters into str
question
7
answer
Which line in the following program will cause a compiler error? 1 #include 2 using namespace std; 3 4 int main() 5 { 6 const int MY_VAL = 99; 7 MY_VAL = 77; 8 cout << MY_VAL << endl; 9 return 0; 10 }
question
fixed
answer
This stream manipulator forces cout to print the digits in fixed-point notation.
question
Parentheses
answer
When converting some algebraic expressions to C++, you may need to insert ___________ that do not appear in the algebraic expression.
question
number = number + 1;
answer
Which statement is equivalent to the following? number += 1;
question
x *= 2;
answer
Which statement is equivalent to the following? x = x * 2;
question
false
answer
The statement cout << setprecision(5) << dollar << endl; will output $5.00 to the screen.
question
3 * 2
answer
In the following C++ statement, what will be executed first according to the order of precedence? result = 6 - 3 * 2 + 7 - 10 / 2;
question
True
answer
When C++ is working with an operator, it strives to convert the operands to the same type.
question
(Parentheses)
answer
You can use these to override the rules of operator precedence in a mathematical expression.
question
39
answer
What is the value of number after the following statements execute? int number = 10; number += 5; number -= 2; number *= 3;
question
2
answer
What will the value of result be after the following statement executes? result = 6 - 3 * 2 + 7 - 10 / 2;
question
4.0
answer
What is the value of average after the following code executes? double average; average = 1.0 + 2.0 + 3.0 / 3.0;
question
true
answer
The cin >> statement will stop reading input when it encounters a newline character.
question
setw
answer
This manipulator is used to establish a field width for the value immediately following it.
question
>>, <<
answer
The ______ operator always follows the cin object, and the ______ operator follows the cout object.
question
-3
answer
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
cin object
answer
The _________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed.
question
13
answer
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
overflows
answer
When a variable is assigned a number that is too large for its data type, it:
question
getline(cin, address);
answer
Which statement will read an entire line of input into the following string object? string address;
question
cstdlib
answer
To use the rand() function, you must #include this header file in your program.
Get an explanation on any task
Get unstuck with the help of our AI assistant in seconds
New