How can we help?

You can also find more resources in our Help Center.

25 terms

COP1334 C++ Midterm (Ch. 3)

STUDY
PLAY
+
When this operator is used with string operands it concatenates them, or joins them together.
data type of the variable
When the final value of an expression is assigned to a variable, it will be converted to:
left to right
Associativity is either right to left or
Ten
The statement

cin >> setw(10) >> str;

will read up to this many characters into str
7
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 = 99;
7 MY_VAL = 77;
8 cout << MY_VAL << endl;
9 return 0;
10 }
fixed
This stream manipulator forces cout to print the digits in fixed-point notation.
Parentheses
When converting some algebraic expressions to C++, you may need to insert ___________ that do not appear in the algebraic expression.
number = number + 1;
Which statement is equivalent to the following?

number += 1;
x *= 2;
Which statement is equivalent to the following?

x = x * 2;
false
The statement

cout << setprecision(5) << dollar << endl;

will output $5.00 to the screen.
3 * 2
In the following C++ statement, what will be executed first according to the order of precedence?

result = 6 - 3 * 2 + 7 - 10 / 2;
True
When C++ is working with an operator, it strives to convert the operands to the same type.
(Parentheses)
You can use these to override the rules of operator precedence in a mathematical expression.
39
What is the value of number after the following statements execute?

int number = 10;
number += 5;
number -= 2;
number *= 3;
2
What will the value of result be after the following statement executes?

result = 6 - 3 * 2 + 7 - 10 / 2;
4.0
What is the value of average after the following code executes?

double average;
average = 1.0 + 2.0 + 3.0 / 3.0;
true
The cin >> statement will stop reading input when it encounters a newline character.
setw
This manipulator is used to establish a field width for the value immediately following it.
>>, <<
The ______ operator always follows the cin object, and the ______ operator follows the cout object.
-3
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;
cin object
The _________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed.
13
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;
overflows
When a variable is assigned a number that is too large for its data type, it:
getline(cin, address);
Which statement will read an entire line of input into the following string object?

string address;
cstdlib
To use the rand() function, you must #include this header file in your program.