Filters
Question type

Study Flashcards

When a program uses the setw manipulator, the iosetwidth header file must be included in a preprocessor directive.

A) True
B) False

Correct Answer

verifed

verified

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

F) B) and C)
G) A) and B)

Correct Answer

verifed

verified

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;

F) D) and E)
G) B) and E)

Correct Answer

verifed

verified

B

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

F) A) and E)
G) B) and C)

Correct Answer

verifed

verified

The fixed manipulator causes a number to be displayed in scientific notation.

A) True
B) False

Correct Answer

verifed

verified

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.

A) True
B) False

Correct Answer

verifed

verified

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

F) A) and B)
G) C) and D)

Correct Answer

verifed

verified

Which line in the following program will cause a compiler error? 1 \quad #include <iostream> 2 \quad using namespace std; 3 4 \quad int main() 5 \quad { 6 \quad\quad const int MY_VAL; 7 \quad\quad MY_VAL = 77; 8 \quad\quad cout << MY_VAL << endl; 9 \quad\quad return 0; 10 \quad }


A) 6
B) 8
C) 9
D) 7

E) C) and D)
F) B) and D)

Correct Answer

verifed

verified

A

The cin << statement will stop reading input when it encounters a newline character.

A) True
B) False

Correct Answer

verifed

verified

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

E) None of the above
F) A) and C)

Correct Answer

verifed

verified

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

F) A) and B)
G) All of the above

Correct Answer

verifed

verified

Which statement is equivalent to the following? x = x * 2;


A) x * 2;
B) x *= 2;
C) x = x * x;
D) None of these

E) All of the above
F) A) and B)

Correct Answer

verifed

verified

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


A) cstdlib
B) cmath
C) cstring
D) iostream
E) iomanip
)

F) A) and D)
G) A) and B)

Correct Answer

verifed

verified

B

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

F) B) and E)
G) All of the above

Correct Answer

verifed

verified

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

F) A) and E)
G) B) and E)

Correct Answer

verifed

verified

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

F) C) and D)
G) A) and C)

Correct Answer

verifed

verified

When C++ is working with an operator, it strives to convert the operands to the same type.

A) True
B) False

Correct Answer

verifed

verified

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


A) cstdlib
B) cmath
C) cstring
D) iostream
E) iomanip

F) B) and E)
G) C) and E)

Correct Answer

verifed

verified

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


A) &
B) *
C) %
D) +
E) None of the above

F) B) and E)
G) A) and B)

Correct Answer

verifed

verified

In C++, it is impossible to display the number 34.789 in a field of 9 spaces with 2 decimal places of precision.

A) True
B) False

Correct Answer

verifed

verified

Showing 1 - 20 of 44

Related Exams

Show Answer