Chapter 3 Flashcards

1
Q

Which is correct?

cout&raquo_space;

cout

A

cout

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which is correct?

cin&raquo_space;

cin

A

cin&raquo_space; .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the preferred expression to promote or demote a value?

A

static_cast

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Variables:
int a=5, b=12
double x=3.4, z=9.1

What is the value of the expression?

b/a

A

2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Variables:
int a=5, b=12
double x=3.4, z=9.1

What is the value of the expression?

x*a

A

17.0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Variables:
int a=5, b=12
double x=3.4, z=9.1

What is the value of the expression?

static_cast”“(b/a)

A

2.0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Variables:
int a=5, b=12
double x=3.4, z=9.1

What is the value of the expression?

static_cast(b) / a

A

2.4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Stream Manipulator

setw(n)

A

Sets minimum print field width for the next value output.

Only set for one output

Right-justified default

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Stream Manipulator

fixed

A

Displays floating-point numbers in fixed-point (I.e., decimal) form

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Stream Manipulator

setprecision(n)

A

Sets the precision of floating point numbers. (Significant digits)

Use with fixed and setprecision(2) to show two decimal points (amounts)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Stream Manipulator

showpoint

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Stream Manipulator

left

A

Subsequent output will be left justified until changed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Stream Manipulator

right

A

Subsequent output will be right-justified until changed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Stream Manipulator

What header file is needed to use stream manipulators?

A

include iomanip

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you allow input with spaces?

A

getline(cin, inputLine)

inputLine is the name of the string variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Member functions

How do you add 22 spaces to a string function?

A

spaces.assign(22, ‘ ‘);

17
Q

How do you find the number of characters in a string called fullName?

A

X = fullName.length()