Chapter 3 Flashcards
Which is correct?
cout»_space;
cout
cout
Which is correct?
cin»_space;
cin
cin»_space; .
What is the preferred expression to promote or demote a value?
static_cast
Variables:
int a=5, b=12
double x=3.4, z=9.1
What is the value of the expression?
b/a
2
Variables:
int a=5, b=12
double x=3.4, z=9.1
What is the value of the expression?
x*a
17.0
Variables:
int a=5, b=12
double x=3.4, z=9.1
What is the value of the expression?
static_cast”“(b/a)
2.0
Variables:
int a=5, b=12
double x=3.4, z=9.1
What is the value of the expression?
static_cast(b) / a
2.4
Stream Manipulator
setw(n)
Sets minimum print field width for the next value output.
Only set for one output
Right-justified default
Stream Manipulator
fixed
Displays floating-point numbers in fixed-point (I.e., decimal) form
Stream Manipulator
setprecision(n)
Sets the precision of floating point numbers. (Significant digits)
Use with fixed and setprecision(2) to show two decimal points (amounts)
Stream Manipulator
showpoint
Causes a decimal point and trailing zeroes to be displayed for floating-point numbers, even if there is no fractional part
defaults to 6 significant digits, unless specified with setprecision(n)
Stream Manipulator
left
Subsequent output will be left justified until changed.
Stream Manipulator
right
Subsequent output will be right-justified until changed.
Stream Manipulator
What header file is needed to use stream manipulators?
include iomanip
How do you allow input with spaces?
getline(cin, inputLine)
inputLine is the name of the string variable.