CIS C++ Chapter 3 Quiz
This function tells the cin object to skip one or more characters in the keyboard buffer.
cin.ignore
The function, pow(x, 5.0), may require this header file.
cmath
When using the sqrt function you must include this header file.
cmath
To use the rand() function, you must #include this header file in your program.
cstdlib
This stream manipulator forces cout to print he digits in fixed-point notation.
fixed
___ reads a line of input, including leading and embedded spaces, and stores it in a string object.
getline
Which statement will read an entire line of input into the following string object? string address;
getline(cin, address);
In any program that uses the cin object, you must include the ___.
iostream header file
This manipulator causes the field to be left-justified with padding spaces printed to the right.
left
Which sstatement is equivalent to the following? number += 1;
number = number + 1;
You can use these to override the rules of operator precedence in a mathematical expression.
(Parantheses)
The ___ operator always follows the cin object, and the ___ operator follows the cout object.
>>, <<
Which statement is equivalent to the following? x = x * 2;
x *= 2;
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;
13
When a variable is assigned a number that is too large for its data type, it:
overflows
Which is true about the following statement? cout << setw(4) << num4 << " ";
It allows four spaces for the value in the variable num4.
Associativity is either right to left or:
Left to right
When converting some algebraic expressions to C++, you may need to insert ___ that do not appear in the algebraic expression.
Parantheses
When the final value of an expression is assigned to a variable, it will be converted to:
The data type of the variable
This statement will pause the screen, until the [Enter] key is pressed.
cin.get();
You want to the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written?
cin >> length >> width >> height;
The ___ causes a program to wait until information is typed at the keyboard and the Enter key is pressed.
cin object
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;
-3
What is the value stored at x, given the statements: int x; x = 3 / static_cast(4,5 + 6.5);
0
What will the value of result be after the following statement executes? result = 6 - 3 * 2 + 7 - 10 / 2;
2
In the following C++ statement, what will be executed first according to the order of precedence? result = 6 - 3 * 2 + 7 - 10 / 2;
3 * 2
What os the value of number after the following statements execute? int number = 10; number += 5; number -= 2; number *= 3;
39
What is the value of average after the following code executes? double average = 1.0 + 2.0 + 3.0 / 3.0;
4.0
When this operator is used with string operands it concatenates them, or joins them together.
+
This manipulator is used to establish a field width for the value immediately following it
setw