Quiz 3: Input/Output Streams (Module 3)

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

In an output statement, each occurrence of endl advances the cursor to the end of the current line on an output device. (true or false?)

False

The following statements will result in input failure if the input values are not on a separate line. (Assume that x and y are int variables.) cin >> x; cin >> y;

False

When reading data into a char variable, after skipping any leading whitespace characters, the extraction operator >> finds and stores only the next character; reading stops after a single character. (True of False?)

True

You can use the function getline to read a string containing blanks. (true or false?)

True

Suppose that ch1 and ch2 are char variables and the input is: WXYZ What is the value of ch2 after the following statements execute?cin.get(ch1); cin.putback(ch1); cin >> ch2;

W

Suppose that alpha is an int variable and ch is a char variable. The input is: ​ 17 A ​ What are the values after the following statements execute? ​ cin >> alpha; cin >> ch; ​

alpha = 17, ch = 'A'

Suppose that x is an int variable and y is a double variable. The input is: ​ 10 20.7 ​ Choose the values after the following statement executes: cin >> x >> y;.

x = 10, y = 20.7

Suppose that x and y are int variables, and z is a double variable. The input is: ​ 28 32.6 12 ​ Choose the values of x, y, and z after the following statement executes: ​ cin >> x >> y >> z;

x = 28, y = 32, z = 0.6

Suppose that ch1, ch2, and ch3 are variables of the type char. The input is: ​ A B C ​ What is the value of ch3 after the following statements execute? ​ cin.get(ch1); cin.get(ch2); cin.get(ch3);

'B'

What is the output of the following statements? cout << setfill('*'); cout << "12345678901234567890" << endl cout << setw(5) << "18" << setw(7) << "Happy"<< setw(8) << "Sleepy" << endl;

12345678901234567890 ***18**Happy**Sleepy

Suppose that x = 1565.683, y = 85.78, and z = 123.982. What is the output of the following statements? cout << fixed << showpoint; cout << setprecision(3) << x << ' '; cout << setprecision(4) << y << ' ' << setprecision(2) << z << endl;

1565.683 85.7800 123.98

Suppose that x = 25.67, y = 356.876, and z = 7623.9674. What is the output of the following statements? cout << fixed << showpoint; cout << setprecision(2); cout << x << ' ' << y << ' ' << z << endl;

25.67 356.88 7623.97

Suppose that alpha, beta, and gamma are int variables and the input is: 100 110 120 200 210 220 300 310 320 What is the value of gamma after the following statements execute?cin >> alpha; cin.ignore(100, '\n'); cin >> beta; cin.ignore(100,'\n'); cin >> gamma;

300

The number of input data extracted by cin and >> depends on the number of variables appearing in the cin statement. (true or false?)

True

Suppose that x is an int variable, ch is a char variable, and the input is: 276 .Choose the values after the following statement executes: cin >> ch >> x;

ch = '2', x = 76

Suppose that ch1 and ch2 are char variables, and alpha is an int variable. The input is: ​ A 18 ​ What are the values after the following statement executes? ​ cin.get(ch1); cin.get(ch2); cin >> alpha;

ch1 = 'A', ch2 = ' ', alpha = 18

Suppose that x and y are int variables. Which of the following is a valid input statement?

cin >> x >> y;

When you want to process only partial data, you can use the stream function ____ to discard a portion of the input.

ignore

​In C++, the dot is an operator called the ____ operator.

member access

Entering a char value into an int variable causes serious errors, called input failure. (true or False?)

true


Set pelajaran terkait

L'hémogramme : définition, variations physiologiques et valeurs pathologiques

View Set

interpersonal communication Exam 1

View Set

Saunders Ch.64 - Foundations of Mental Health Nursing Questions w/ Rationale

View Set

WCS Fill in Blank: Light, Mirrors, and Lenses

View Set