Chapter 3 Quiz

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

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;

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

This manipulator forces cout to print digits in fixed-point notation:

fixed

Which of the following statements will read an entire line of input into the string object, address?

getline(cin, address);

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 }

line 7

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

overflows

Which of the following functions will return the value of x, rounded to the nearest whole number?

round(x)

You can control the number of significant digits in your output with the ________ manipulator.

setprecision

This manipulator is used to establish a field width for the value that follows it:

setw

How many characters will the following statement read into the variable myString? cin >> setw(10) >> myString;

9

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

>>, <<

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

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

What will be displayed after the following statements execute? int num1 = 5;int num2 = 3;cout << "The result is " << (num1 * num2 + 10) << endl;

The result is 25

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

getline

What is the value of result after the following statement executes?result = (3 * 5) % 4 + 24 / (15 - (7 - 4));

-6.4

What is the value of x after the following code executes? x = 3 / static_cast<int>(4.5 + 6.4);

0

What is the value of average after the following code executes? double average; average = 1.0 + 2.0 + 3.0 / 3.0;

4

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

True

In the following statement, what will be executed first according to the order of precedence? result = 6 - 3 * 2 + 7 - 10 / 2;

b. 3 * 2

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

b. type conversion

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?

cin >> base >> height

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

cin object

Which of the following statements will pause the screen until the [Enter] key is pressed?

cin.get();

Which of the following functions tells the cin object to skip one or more characters in the keyboard buffer?

cin.ignore


Kaugnay na mga set ng pag-aaral

PRCC Mrs. Torchia - Job Search Skills Final Exam

View Set