Deck 3: Expressions and Interactivity

Full screen (f)
exit full mode
Question
This function tells the cin object to skip one or more characters in the keyboard buffer.

A)cin.ignore
B)cin.jump
C)cin.hop
D)cin.skip;
E)None of the above
Use Space or
up arrow
down arrow
to flip the card.
Question
The ________ operator always follows the cin object, and the ________ operator follows the cout object.

A)binary, unary
B)conditional, binary
C)>>, <<
D)<<, >>
E)None of the above
Question
When the final value of an expression is assigned to a variable, it will be converted to:

A)The smallest C++ data type
B)The largest C++ data type
C)The data type of the variable
D)The data type of the expression
E)None of the above
Question
This statement will pause the screen, until the [Enter] key is pressed.

A) <strong>This statement will pause the screen, until the [Enter] key is pressed.</strong> A)   B)   C)   D)   E)   <div style=padding-top: 35px>
B) <strong>This statement will pause the screen, until the [Enter] key is pressed.</strong> A)   B)   C)   D)   E)   <div style=padding-top: 35px>
C) <strong>This statement will pause the screen, until the [Enter] key is pressed.</strong> A)   B)   C)   D)   E)   <div style=padding-top: 35px>
D) <strong>This statement will pause the screen, until the [Enter] key is pressed.</strong> A)   B)   C)   D)   E)   <div style=padding-top: 35px>
E) <strong>This statement will pause the screen, until the [Enter] key is pressed.</strong> A)   B)   C)   D)   E)   <div style=padding-top: 35px>
Question
To use the rand()function, you must #include this header file in your program.

A)iostream
B)iomanip
C)iorand
D)cstdlib
E)None of these
Question
When this operator is used with string operands it concatenates them, or joins them together.

A)&
B)*
C)%
D)+
E)None of the above
Question
Which statement will read an entire line of input into the following string object?
String address;

A)cin << address;
B)cin address;
C)getline(cin, address);
D)cin.get(address);
E)None of the above
Question
You can use these to override the rules of operator precedence in a mathematical expression.

A)[Brackets]
B)(Parentheses)
C){Braces}
D)The escape character \
E)None of these
Question
Associativity is either right to left or:

A)Top to bottom
B)Front to back
C)Left to right
D)Undeterminable
E)None of the above
Question
When a variable is assigned a number that is too large for its data type, it:

A)underflows
B)overflows
C)reverses polarity
D)exceeds expectations
E)None of the above
Question
The ________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed.

A)Output stream
B) <strong>The ________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed.</strong> A)Output stream B)   C)   D)Preprocessor E)None of the above <div style=padding-top: 35px>
C) <strong>The ________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed.</strong> A)Output stream B)   C)   D)Preprocessor E)None of the above <div style=padding-top: 35px>
D)Preprocessor
E)None of the above
Question
In the following C++ statement, what will be executed first according to the order of precedence?
<strong>In the following C++ statement, what will be executed first according to the order of precedence?  </strong> A)6 - 3 B)3 * 2 C)2 + 7 D)7 - 10 E)10 / 2 <div style=padding-top: 35px>

A)6 - 3
B)3 * 2
C)2 + 7
D)7 - 10
E)10 / 2
Question
Assume that x is an int variable. What value is assigned to x after the following assignment statement is executed?
<strong>Assume that x is an int variable. What value is assigned to x after the following assignment statement is executed?  </strong> A)0 B)1 C)2 D)-3 E)None of these <div style=padding-top: 35px>

A)0
B)1
C)2
D)-3
E)None of these
Question
What is the value stored at x, given the statements:
<strong>What is the value stored at x, given the statements:  </strong> A).3 B)0 C).275229 D)3.3 E)None of these <div style=padding-top: 35px>

A).3
B)0
C).275229
D)3.3
E)None of these
Question
This manipulator is used to establish a field width for the value immediately following it.

A)field_width
B)set_field
C)setw
D)iomanip
E)None of the above
Question
You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written?

A) <strong>You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written?</strong> A)   B)   C)   D)   E)   <div style=padding-top: 35px>
B) <strong>You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written?</strong> A)   B)   C)   D)   E)   <div style=padding-top: 35px>
C) <strong>You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written?</strong> A)   B)   C)   D)   E)   <div style=padding-top: 35px>
D) <strong>You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written?</strong> A)   B)   C)   D)   E)   <div style=padding-top: 35px>
E) <strong>You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written?</strong> A)   B)   C)   D)   E)   <div style=padding-top: 35px>
Question
In any program that uses the cin object, you must include the ________.

A)compiler
B)iostream header file
C)linker
D)>> and << operators
E)None of the above
Question
The function, pow(x, 5.0), requires this header file.

A)cstdlib
B)cmath
C)cstring
D)iostream
E)iomanip
Question
This manipulator causes the field to be left-justified with padding spaces printed to the right.

A)left_justify
B)right
C)left
D)left_pad
E)None of these
Question
________ reads a line of input, including leading and embedded spaces, and stores it in a string object.

A)cin.get
B)getline
C)cin.getline
D)get
E)None of these
Question
Which statement is equivalent to the following?
Number += 1;

A)number = number + 1;
B)number + 1;
C)number = 1;
D)None of these
Question
Which line in the following program will cause a compiler error?
<strong>Which line in the following program will cause a compiler error?  </strong> A)6 B)8 C)9 D)7 <div style=padding-top: 35px>

A)6
B)8
C)9
D)7
Question
What is the value of number after the following statements execute?
<strong>What is the value of number after the following statements execute?  </strong> A)3 B)30 C)39 D)2 <div style=padding-top: 35px>

A)3
B)30
C)39
D)2
Question
Which line in the following program will cause a compiler error?
<strong>Which line in the following program will cause a compiler error?  </strong> A)6 B)8 C)9 D)7 <div style=padding-top: 35px>

A)6
B)8
C)9
D)7
Question
The total number of digits that appear before and after the decimal point is sometimes referred to as:

A)floating points
B)significant digits
C)precision
D)B and C
E)None of these
Question
When C++ is working with an operator, it strives to convert the operands to the same type.
Question
This stream manipulator forces cout to print the digits in fixed-point notation.

A)setprecision(2)
B)setw(2)
C)fixed
D)setfixed(2)
E)None of these
Question
When converting some algebraic expressions to C++, you may need to insert ________ that do not appear in the algebraic expression.

A)Parentheses
B)Exponents
C)Calculations
D)Coercions
E)None of the above
Question
When using the sqrt function you must include this header file.

A)cstdlib
B)cmath
C)cstring
D)iostream
E)iomanip
Question
When the fixed manipulator is used, the value specified by the setprecision manipulator will be the number of digits to appear after the decimal point.
Question
What is the value of average after the following code executes?
<strong>What is the value of average after the following code executes?  </strong> A)2.0 B)4.0 C)1.5 D)6.0 <div style=padding-top: 35px>

A)2.0
B)4.0
C)1.5
D)6.0
Question
The cin << statement will stop reading input when it encounters a newline character.
Question
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.
Question
What will the value of result be after the following statement executes?
<strong>What will the value of result be after the following statement executes?  </strong> A)8 B)6 C)1.5 D)2 <div style=padding-top: 35px>

A)8
B)6
C)1.5
D)2
Question
The statement:
<strong>The statement:   Will read up to this many characters into str.</strong> A)Nine B)Ten C)Eleven D)Eight E)None of these <div style=padding-top: 35px>
Will read up to this many characters into str.

A)Nine
B)Ten
C)Eleven
D)Eight
E)None of these
Question
Arithmetic operators that share the same precedence have right to left associativity.
Question
Which is true about the following statement?
<strong>Which is true about the following statement?  </strong> A)It allows four spaces for the value in the variable num4. B)It outputs setw(4) before the value in the variable num4. C)It should use setw(10)to output the value in the variable num10. D)It inputs up to four characters stored in the variable num4. E)None of these <div style=padding-top: 35px>

A)It allows four spaces for the value in the variable num4.
B)It outputs "setw(4)" before the value in the variable num4.
C)It should use setw(10)to output the value in the variable num10.
D)It inputs up to four characters stored in the variable num4.
E)None of these
Question
Which statement is equivalent to the following?
X = x * 2;

A)x * 2;
B)x *= 2;
C)x = x * x;
D)None of these
Question
What will the value of x be after the following statements execute?
<strong>What will the value of x be after the following statements execute?  </strong> A)13 B)18 C)0 D)unknown <div style=padding-top: 35px>

A)13
B)18
C)0
D)unknown
Question
If you want to know the length of the string that is stored in a string object, you can call the object's size member function.
Question
The following statement will output $5.00 to the screen:
cout << setprecision(5)<< dollars << endl;
Question
The fixed manipulator causes a number to be displayed in scientific notation.
Question
In C++, it is impossible to display the number 34.789 in a field of 9 spaces with 2 decimal places of precision.
Question
When a program uses the setw manipulator, the iosetwidth header file must be included in a preprocessor directive.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/44
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 3: Expressions and Interactivity
1
This function tells the cin object to skip one or more characters in the keyboard buffer.

A)cin.ignore
B)cin.jump
C)cin.hop
D)cin.skip;
E)None of the above
cin.ignore
2
The ________ operator always follows the cin object, and the ________ operator follows the cout object.

A)binary, unary
B)conditional, binary
C)>>, <<
D)<<, >>
E)None of the above
>>, <<
3
When the final value of an expression is assigned to a variable, it will be converted to:

A)The smallest C++ data type
B)The largest C++ data type
C)The data type of the variable
D)The data type of the expression
E)None of the above
The data type of the variable
4
This statement will pause the screen, until the [Enter] key is pressed.

A) <strong>This statement will pause the screen, until the [Enter] key is pressed.</strong> A)   B)   C)   D)   E)
B) <strong>This statement will pause the screen, until the [Enter] key is pressed.</strong> A)   B)   C)   D)   E)
C) <strong>This statement will pause the screen, until the [Enter] key is pressed.</strong> A)   B)   C)   D)   E)
D) <strong>This statement will pause the screen, until the [Enter] key is pressed.</strong> A)   B)   C)   D)   E)
E) <strong>This statement will pause the screen, until the [Enter] key is pressed.</strong> A)   B)   C)   D)   E)
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
5
To use the rand()function, you must #include this header file in your program.

A)iostream
B)iomanip
C)iorand
D)cstdlib
E)None of these
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
6
When this operator is used with string operands it concatenates them, or joins them together.

A)&
B)*
C)%
D)+
E)None of the above
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
7
Which statement will read an entire line of input into the following string object?
String address;

A)cin << address;
B)cin address;
C)getline(cin, address);
D)cin.get(address);
E)None of the above
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
8
You can use these to override the rules of operator precedence in a mathematical expression.

A)[Brackets]
B)(Parentheses)
C){Braces}
D)The escape character \
E)None of these
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
9
Associativity is either right to left or:

A)Top to bottom
B)Front to back
C)Left to right
D)Undeterminable
E)None of the above
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
10
When a variable is assigned a number that is too large for its data type, it:

A)underflows
B)overflows
C)reverses polarity
D)exceeds expectations
E)None of the above
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
11
The ________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed.

A)Output stream
B) <strong>The ________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed.</strong> A)Output stream B)   C)   D)Preprocessor E)None of the above
C) <strong>The ________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed.</strong> A)Output stream B)   C)   D)Preprocessor E)None of the above
D)Preprocessor
E)None of the above
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
12
In the following C++ statement, what will be executed first according to the order of precedence?
<strong>In the following C++ statement, what will be executed first according to the order of precedence?  </strong> A)6 - 3 B)3 * 2 C)2 + 7 D)7 - 10 E)10 / 2

A)6 - 3
B)3 * 2
C)2 + 7
D)7 - 10
E)10 / 2
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
13
Assume that x is an int variable. What value is assigned to x after the following assignment statement is executed?
<strong>Assume that x is an int variable. What value is assigned to x after the following assignment statement is executed?  </strong> A)0 B)1 C)2 D)-3 E)None of these

A)0
B)1
C)2
D)-3
E)None of these
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
14
What is the value stored at x, given the statements:
<strong>What is the value stored at x, given the statements:  </strong> A).3 B)0 C).275229 D)3.3 E)None of these

A).3
B)0
C).275229
D)3.3
E)None of these
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
15
This manipulator is used to establish a field width for the value immediately following it.

A)field_width
B)set_field
C)setw
D)iomanip
E)None of the above
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
16
You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written?

A) <strong>You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written?</strong> A)   B)   C)   D)   E)
B) <strong>You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written?</strong> A)   B)   C)   D)   E)
C) <strong>You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written?</strong> A)   B)   C)   D)   E)
D) <strong>You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written?</strong> A)   B)   C)   D)   E)
E) <strong>You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written?</strong> A)   B)   C)   D)   E)
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
17
In any program that uses the cin object, you must include the ________.

A)compiler
B)iostream header file
C)linker
D)>> and << operators
E)None of the above
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
18
The function, pow(x, 5.0), requires this header file.

A)cstdlib
B)cmath
C)cstring
D)iostream
E)iomanip
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
19
This manipulator causes the field to be left-justified with padding spaces printed to the right.

A)left_justify
B)right
C)left
D)left_pad
E)None of these
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
20
________ reads a line of input, including leading and embedded spaces, and stores it in a string object.

A)cin.get
B)getline
C)cin.getline
D)get
E)None of these
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
21
Which statement is equivalent to the following?
Number += 1;

A)number = number + 1;
B)number + 1;
C)number = 1;
D)None of these
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
22
Which line in the following program will cause a compiler error?
<strong>Which line in the following program will cause a compiler error?  </strong> A)6 B)8 C)9 D)7

A)6
B)8
C)9
D)7
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
23
What is the value of number after the following statements execute?
<strong>What is the value of number after the following statements execute?  </strong> A)3 B)30 C)39 D)2

A)3
B)30
C)39
D)2
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
24
Which line in the following program will cause a compiler error?
<strong>Which line in the following program will cause a compiler error?  </strong> A)6 B)8 C)9 D)7

A)6
B)8
C)9
D)7
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
25
The total number of digits that appear before and after the decimal point is sometimes referred to as:

A)floating points
B)significant digits
C)precision
D)B and C
E)None of these
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
26
When C++ is working with an operator, it strives to convert the operands to the same type.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
27
This stream manipulator forces cout to print the digits in fixed-point notation.

A)setprecision(2)
B)setw(2)
C)fixed
D)setfixed(2)
E)None of these
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
28
When converting some algebraic expressions to C++, you may need to insert ________ that do not appear in the algebraic expression.

A)Parentheses
B)Exponents
C)Calculations
D)Coercions
E)None of the above
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
29
When using the sqrt function you must include this header file.

A)cstdlib
B)cmath
C)cstring
D)iostream
E)iomanip
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
30
When the fixed manipulator is used, the value specified by the setprecision manipulator will be the number of digits to appear after the decimal point.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
31
What is the value of average after the following code executes?
<strong>What is the value of average after the following code executes?  </strong> A)2.0 B)4.0 C)1.5 D)6.0

A)2.0
B)4.0
C)1.5
D)6.0
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
32
The cin << statement will stop reading input when it encounters a newline character.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
33
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.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
34
What will the value of result be after the following statement executes?
<strong>What will the value of result be after the following statement executes?  </strong> A)8 B)6 C)1.5 D)2

A)8
B)6
C)1.5
D)2
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
35
The statement:
<strong>The statement:   Will read up to this many characters into str.</strong> A)Nine B)Ten C)Eleven D)Eight E)None of these
Will read up to this many characters into str.

A)Nine
B)Ten
C)Eleven
D)Eight
E)None of these
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
36
Arithmetic operators that share the same precedence have right to left associativity.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
37
Which is true about the following statement?
<strong>Which is true about the following statement?  </strong> A)It allows four spaces for the value in the variable num4. B)It outputs setw(4) before the value in the variable num4. C)It should use setw(10)to output the value in the variable num10. D)It inputs up to four characters stored in the variable num4. E)None of these

A)It allows four spaces for the value in the variable num4.
B)It outputs "setw(4)" before the value in the variable num4.
C)It should use setw(10)to output the value in the variable num10.
D)It inputs up to four characters stored in the variable num4.
E)None of these
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
38
Which statement is equivalent to the following?
X = x * 2;

A)x * 2;
B)x *= 2;
C)x = x * x;
D)None of these
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
39
What will the value of x be after the following statements execute?
<strong>What will the value of x be after the following statements execute?  </strong> A)13 B)18 C)0 D)unknown

A)13
B)18
C)0
D)unknown
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
40
If you want to know the length of the string that is stored in a string object, you can call the object's size member function.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
41
The following statement will output $5.00 to the screen:
cout << setprecision(5)<< dollars << endl;
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
42
The fixed manipulator causes a number to be displayed in scientific notation.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
43
In C++, it is impossible to display the number 34.789 in a field of 9 spaces with 2 decimal places of precision.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
44
When a program uses the setw manipulator, the iosetwidth header file must be included in a preprocessor directive.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 44 flashcards in this deck.