COP 3014 Chapter 3

¡Supera tus tareas y exámenes ahora con Quizwiz!

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

False

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

False

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

False

Arithmetic operators that share the same precedence have right to left associativity.

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

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

False

What is the value of x after the following code executes? int x; x = 3 / static_cast<int>(4.5 + 6.4); a. 0.3 b. 0 c. 0.275229 d. 3.3 e. None of these

b. 0

In the following 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. 10 / 2 e. 7 - 10

b. 3 * 2

What is the value of result after the following statement executes? result = (3 * 5) % 4 + 24 / (15 - (7 - 4)); a. -6.4 b. 5 c. 1.6 d. 2.25 e. None of these

b. 5

What is the value of cube after the following code executes? double cube, side; side = 5.0; cube = pow(side, 3.0); a. 25.0 b. 15.0 c. 125.0 d. 8.0 e. unknown

c. 125.0

What is the value of x after the following code executes? int x = 0; int y = 5; int z = 4; x = x + y + z * 2; a. 18 b. 0 c. 13 d. 26 e. unknown

c. 13

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

True

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

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

True

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

How many characters will the following statement read into the variable myString? cin >> setw(10) >> myString; a. 9 b. 10 c. 11 d. however many characters are in myString e. None of these

a. 9

What is true about the following statement? cout << setw(4) << num4 << " "; a. It allows four spaces for the value in num4. b. It outputs "setw(4)" before the value in num4. c. It is incorrect because it should use setw(10). d. It is incorrect because it should use setw(num4).

a. It allows four spaces for the value in num4.

Which of the following functions 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 these

a. cin.ignore

To use the rand()function, you must include the __________ header file? a. cstdlib b. cstring c. iostream d. cmath e. iomanip

a. cstdlib

Which statement is equivalent to the following? number += 1; a. number = number + 1; b. number = 1; c. number + 1; d. number =+ 1; e. None of these

a. number = number + 1;

You can control the number of significant digits in your output with the __________ manipulator. a. setprecision b. set_precision c. to_fixed d. setfixed() e. None of these

a. setprecision

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 these

b. cin object

. __________ 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. getline

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. line 6 b. line 7 c. line 8 d. line 9 e. there will be no compiler error

b. line 7

Which statement is equivalent to the following? number = number * 2; a. number = pow(number, 2); b. number *= 2; c. number = number * number; d. number * 2 = number; e. None of these

b. number *= 2;

When a variable is assigned a number that is too large for its data type, it a. underflows b. overflows c. reverses d. converts e. None of these

b. overflows

Which of the following must be included in any program that uses the cin object? a. compiler b. the header file iostream c. linker d. brackets e. None of these

b. the header file iostream

When C++ is working with an operator, it strives to convert operands to the same type. This is known as a. type correction b. type conversion c. promotion d. demotion e. None of these

b. type conversion

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. 39 d. 2 e. None of these

c. 39

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. 3.0 c. 4.0 d. 2 e. unknown

c. 4.0

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 these

c. >>, <<

What will be displayed after the following statements execute? int num1 = 5; int num2 = 3; cout << "The result is " << (num1 * num2 + 10) << endl; a. The result is 5 * 3 + 10 b. The result is (num1 * num2 + 10) c. The result is 25 d. The result is 65 e. None of these

c. The result is 25

Which of the following will allow the user to input the values 15 and 20 and have them stored in variables named base and height, respectively? a. cin << base << height; b. cin base, height; c. cin >> base >> height; d. cin base >> cin height; e. None of these

c. cin >> base >> height;

Which of the following statements 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. cin.get();

Which of the following statements will allow the user to enter three values to be stored in variables length, width, and height, in that order? a. cin << length, width, height; b. cin.get(height, width, length); c. cin.get(length, width, height); d. cin >> length; width; height; e. cin.get(length >> width >> height);

c. cin.get(length, width, height);

This manipulator forces cout to print digits in fixed-point notation: a. setprecision(2) b. setw(2) c. fixed d. setfixed(2) e. None of these

c. fixed

A debugging process where you, the programmer, pretend you are a computer and step through each statement while recording the value of each variable at each step is known as a. error checking b. hand writing c. hand tracing d. error handling e. None of these

c. hand tracing

When a user types values at the keyboard, those values are first stored a. as ASCII characters b. in the header file iostream c. in the keyboard buffer d. as integers e. None of these

c. in the keyboard buffer

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. left

Associativity is either right to left or a. top to bottom b. front to back c. left to right d. undeterminable e. None of these

c. left to right

This manipulator is used to establish a field width for the value that follows it: a. field_width b. set_field c. setw d. iomanip e. None of these

c. setw

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 these

c. the data type of the variable

The function pow(x, y), requires which header file? a. cstdlib b. cstring c. iostream d. cmath e. iomanip

d. cmath

Which of the following statements will read an entire line of input into the string object, address? a. cin << address; b. cin address; c. cin.get(address); d. getline(cin, address); e. cin.get(length >> width >> height);

d. getline(cin, address);

Which of the following functions will return the value of x, rounded to the nearest whole number? a. abs(x) b. fmod(x) c. sqrt(x) d. round(x) e. whole(x)

d. round(x)


Conjuntos de estudio relacionados

art appreciation chapters 15,16,17

View Set

PEDS- Chapter 5- "the point review"

View Set

Chapter 5: Viral Structure and Multiplication

View Set

Pop Health Module 5 practice questions

View Set