CSC 150 Quiz 3

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

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 x and y are int variables, z is a double variable, and the input is: 28 32.6 12 Choose the values of x, y, and z after the following statement executes: cin >> x >> y >> z; a. x = 28, y = 32, z = 0.6 b. x = 28, y = 32, z = 12.0 c. x = 28, y = 12, z = 32.6 d. x = 28, y = 12, z = 0.6

a

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

a

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 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= , ch2= , alpha=

'A', ' ', 18

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'

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= , y=

10, 20.7

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 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;

17, 'A'

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; (what displays on screen)

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

Suppose that x and y are int variables. Write a valid input statement?

cin >> x >> y;

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; a. ch = '2', x = 276 b. ch = ' ', x = 276 c. ch = '276', x = '.' d. ch = '2', x = 76

d

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; True or false?

false

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

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

true

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 or false?

true


Conjuntos de estudio relacionados

Social Studies (World History) 107 Checkup 1

View Set

올리버쌤_회화문장(62강) 미국인이 hello보다 더 자주 쓰는 인사말.

View Set

Prime Minister and the Council of Ministers

View Set