Deck 3: Expressions and Interactivity

Full screen (f)
exit full mode
Question
This statement will pause the screen, until the [Enter] key is pressed.

A) cin;
B) cin.getline();
C) cin.get();
D) cin.ignore();
E) cin.input();
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
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
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
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
What is the value stored at x, given the statements: int x;
X = 3 / static_cast(4.5 + 6.4);

A) .3
B) 0
C) .275229
D) 3.3
E) None of these
Question
In the following C++ statement, what will be executed first according to the order of precedence? result = 6 - 3 * 2 + 7 - 10 / 2 ;

A) 6 - 3
B) 3 * 2
C) 2 + 7
D) 7 - 10
E) 10 / 2
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
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
___________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 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
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
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
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;

A) 0
B) 1
C) 2
D) -3
E) None of these
Question
You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written?

A) cin << length, width, height;
B) cin.get(length, width, height);
C) cin >> length >> width >> height;
D) cin >> length, width, height;
E) cin << length; width; height;
Question
The function, pow(x, 5.0), requires this header file.

A) cstdlib
B) cmath
C) cstring
D) iostream
E) iomanip
)
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
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
The _________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed.

A) Output stream
B) cin object
C) cout object
D) Preprocessor
E) None of the above
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
The statement cin >> setw(10) >> str;
Will read up to this many characters into str.

A) Nine
B) Ten
C) Eleven
D) Eight
E) None of these
Question
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;
7 MY_VAL = 77;
8 cout << MY_VAL << endl;
9 return 0;
10 }

A) 6
B) 8
C) 9
D) 7
Question
What is the value of number after the following statements execute? int number = 10;
Number += 5;
Number -= 2;
Number *= 3;

A) 3
B) 30
C) 15
D) 2
Question
Which is true about the following statement? cout << setw(4) << num4 << " ";

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
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
Which statement is equivalent to the following? number += 1;

A) number = number + 1;
B) number + 1;
C) number = 1;
D) None of these
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
What will the value of result be after the following statement executes? result = 6 - 3 * 2 + 7 - 10 / 2 ;

A) 8
B) 6
C) 1.5
D) 2
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
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 = 77;
7 MY_VAL = 99;
8 cout << MY_VAL << endl;
9 return 0;
10 }

A) 6
B) 8
C) 9
D) 7
Question
Arithmetic operators that share the same precedence have right to left associativity.
Question
What is the value of average after the following code executes? double average;
Average = 1.0 + 2.0 + 3.0 / 3.0;

A) 2.0
B) 4.0
C) 1.5
D) 6.0
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 C++ is working with an operator, it strives to convert the operands to the same type.
Question
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;

A) 13
B) 18
C) 0
D) unknown
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
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
The fixed manipulator causes a number to be displayed in scientific notation.
Question
When a program uses the setw manipulator, the iosetwidth header file must be included in a preprocessor directive.
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
The statement
cout << setprecision(5) << dollars << endl;
will output $5.00 to the screen.
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 statement will pause the screen, until the [Enter] key is pressed.

A) cin;
B) cin.getline();
C) cin.get();
D) cin.ignore();
E) cin.input();
C
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
C
3
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
C
4
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
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
5
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
6
What is the value stored at x, given the statements: int x;
X = 3 / static_cast(4.5 + 6.4);

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
7
In the following C++ statement, what will be executed first according to the order of precedence? result = 6 - 3 * 2 + 7 - 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
8
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
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
___________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
11
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
12
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
13
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
14
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;

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
15
You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written?

A) cin << length, width, height;
B) cin.get(length, width, height);
C) cin >> length >> width >> height;
D) cin >> length, width, height;
E) cin << length; width; height;
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
16
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
17
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
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
18
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
19
The _________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed.

A) Output stream
B) cin object
C) cout object
D) Preprocessor
E) None of the above
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
20
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
21
The statement cin >> setw(10) >> str;
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
22
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;
7 MY_VAL = 77;
8 cout << MY_VAL << endl;
9 return 0;
10 }

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? int number = 10;
Number += 5;
Number -= 2;
Number *= 3;

A) 3
B) 30
C) 15
D) 2
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
24
Which is true about the following statement? cout << setw(4) << num4 << " ";

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
25
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
26
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
27
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
28
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
29
What will the value of result be after the following statement executes? result = 6 - 3 * 2 + 7 - 10 / 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
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
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 = 77;
7 MY_VAL = 99;
8 cout << MY_VAL << endl;
9 return 0;
10 }

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
32
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
33
What is the value of average after the following code executes? double average;
Average = 1.0 + 2.0 + 3.0 / 3.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
34
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
35
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
36
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
37
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
38
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;

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
39
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
40
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
41
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
42
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
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
The statement
cout << setprecision(5) << dollars << endl;
will output $5.00 to the screen.
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.