Quiz 3 Flashcards

1
Q

The ________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed.

A

A) Output stream

*B) cin object

C) cout object

D) Preprocessor

E) None of the above

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

The ________ operator always follows the cin object, and the ________ operator follows the cout object.

A

A) binary, unary

B) conditional, binary

*C)&raquo_space;, «

D) <>

E) None of the above

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

________ reads a line of input, including leading and embedded spaces, and stores it in a string object.

A

A) cin.get

*B) getline

C) cin.getline

D) get

E) None of these

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

When this operator is used with string operands it concatenates them, or joins them together.

A

A) &

B) *

C) %

*D) +

E) None of the above

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

What is the value stored at x, given the statements:

 int x;

 x = 3 / static_cast(4.5 + 6.4);
A

A) .3

*B) 0

C) .275229

D) 3.3

E) None of these

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

fix

A

*A) cin.ignore

B) cin.jump

C) cin.hop

D) cin.skip;

E) None of the above

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

The function, pow(x, 5.0), requires this header file.

A

A) cstdlib

*B) cmath

C) cstring

D) iostream

E) iomanip

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

You can use these to override the rules of operator precedence in a mathematical expression.

A

A) [Brackets]

*B) (Parentheses)

C) {Braces}

D) The escape character \

E) None of these

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

When the final value of an expression is assigned to a variable, it will be converted to:

A

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

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

When a variable is assigned a number that is too large for its data type, it:

A

A) underflows

*B) overflows

C) reverses polarity

D) exceeds expectations

E) None of the above

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

This manipulator is used to establish a field width for the value immediately following it.

A

A) field_width

B) set_field

*C) setw

D) iomanip

E) None of the above

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

This manipulator causes the field to be left-justified with padding spaces printed to the right.

A

A) left_justify

B) right

*C) left

D) left_pad

E) None of these

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

This statement will pause the screen, until the [Enter] key is pressed.

Group of answer choices

A

A) cin;

B) cin.getline();

*C) cin.get();

D) cin.ignore();

E) cin.input();

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

To use the rand() function, you must #include this header file in your program.

Group of answer choices

A

A) iostream

B) iomanip

C) iorand

*D) cstdlib

E) None of these

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

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

A) 0

B) 1

C) 2

*D) —3

E) None of these

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

Which statement will read an entire line of input into the following string object?

 string address;
A

A) cin &laquo_space;address;

B) cin address;

*C) getline(cin, address);

D) cin.get(address);

E) None of the above

17
Q

This stream manipulator forces cout to print the digits in fixed-point notation.

A

A) setprecision(2)

B) setw(2)

*C) fixed

D) setfixed(2)

E) None of these

18
Q

When using the sqrt function you must include this header file.

A

A) cstdlib

*B) cmath

C) cstring

D) iostream

E) iomanip

19
Q

The statement:

 cin >> setw(10) >> str;

will read up to this many characters into str.

A

*A) Nine

B) Ten

C) Eleven

D) Eight

E) None of these

20
Q

What will the value of result be after the following statement executes?

 result = 6 - 3 * 2 + 7 - 10 / 2 ;
A

A) 8

B) 6

C) 1.5

*D) 2

21
Q

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

*A) 13

B) 18

C) 0

D) unknown

22
Q

What is the value of average after the following code executes?

 double average;

 average = 1.0 + 2.0 + 3.0 / 3.0;
A

A) 2.0

*B) 4.0

C) 1.5

D) 6.0

23
Q

Which statement is equivalent to the following?

 number += 1;
A

*A) number = number + 1;

B) number + 1;

C) number = 1;

D) None of these

24
Q

Which statement is equivalent to the following?

 x = x * 2;
A

A) x * 2;

*B) x *= 2;

C) x = x * x;

D) None of these

25
Q

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

A) 6

B) 8

C) 9

*D) 7