CSCI Ch 3

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

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

A

True/False: 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.

TRUE

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

B

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

B

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

B

The function, pow(x, 5.0), requires this header file. A) cstdlib B) cmath C) cstring D) iostream E) iomanip

B

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

B

What is the value stored at x, given the statements: int x; x = 3 / static_cast<int>(4.5 + 6.4); A) .3 B) 0 C) .275229 D) 3.3 E) None of these

B

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

B

When using the sqrt function you must include this header file. A) cstdlib B) cmath C) cstring D) iostream E) iomanip

B

Which statement is equivalent to the following? x = x * 2; A) x * 2; B) x *= 2; C) x = x * x; D) None of these

B

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

B

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;

B

________ 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

B

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

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

C

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

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

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

C

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

C

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

C

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

C

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

C

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

D

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

D

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

D

When this operator is used with string operands it concatenates them, or joins them together. A) & B) * C) % D) + E) None of the above

D

Which line in the following program will cause a compiler error? 1 #include <iostream> 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

D

True/False: Arithmetic operators that share the same precedence have right to left associativity.

FALSE

True/False: 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.

FALSE

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

FALSE

True/False: The fixed manipulator causes a number to be displayed in scientific notation.

FALSE

True/False: The following statement will output $5.00 to the screen: cout << setprecision(5) << dollars << endl;

FALSE

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

FALSE

Which line in the following program will cause a compiler error? 1 #include <iostream> 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

A

Which statement is equivalent to the following? number += 1; A) number = number + 1; B) number + 1; C) number = 1; D) None of these

A

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

A

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

A

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

A

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

A

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

D

True/False: The cin << statement will stop reading input when it encounters a newline character.

TRUE

True/False: 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.

TRUE

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

TRUE


Set pelajaran terkait

Renewable & Non-Renewable Energy Sources

View Set

Entrepreneurship 1 Unit 2 Review

View Set

Unit 2: Debt Securities Unit Test

View Set

Illinois Life, Accident and Health Law

View Set

CCA Exam Prep - Reimbursement Methodologies

View Set