C.S. 150 Chapter 3 (Input / Output)

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

To use the manipulators setprecision, setw, and setfill, the program must include the header file ________. A. iostram B. string C. iomanip D. cmath

C. iomanip

Suppose that x and y are int variables, ch is a char variable, and the input is: 4 2 A 12 Choose the values of x, y, and ch after the following statement executes: cin>> x>> ch>> y; A. x = 4, ch= 2, y = 12 B. x = 4, ch= A, y = 12 C. x = 4, ch= ' ', y = 2 D. This statement results in input failure

D. This statement results in input failure

>>is called stream extraction operator. True or False?

True

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

True

The extraction operator >> skips only all leading blanks when searching for the next data in the input stream. True or False?

True

The header file fstream contains the definitions of ifstreamand ofstream. True or False?

True

The manipulator setfill is used to fill the unused columns on an output device with a character other than a space. True or False?

True

The manipulator setprecision formats the output of floating-point numbers to a specified number of decimal places. True or False?

True

The statement outData.close(); closes the file stream outData. True or False?

True

To input data from a file, the program must include the header file fstream. True or False?

True

You can use the function getline to read a string containing blanks. True or False?

True

Suppose that x = 55.68, y = 476.859, and z = 23.8216. What is the output of the following statements? cout<< fixed << showpoint; cout<< setprecision(3); cout<< x << ' ' << y << ' ' << setprecision(2) << z << endl; A. 55.680 476.859 23.82 B. 55.690 476.860 23.82 C. 55.680 476.860 23.82 D. 55.680 476.859 23.821

A. 55.680 476.859 23.82

C++ provides a header file called ____________________, which is used for file I/O. A. fstream B. iomanip C. iostream D. string

A. fstream

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 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. x = 28, y = 32, z = 0.6

Suppose that x and y are int variables. Which of the following is a valid input statement? A. cin>> x >> cin>> y; B. cin>> x >> y; C. cin<< x << y; D. cout<< x << y;

B. cin>> x >> y;

Which header file contains the sqrt function? A. iostream B. cmath C. string D. All the above

B. cmath

An expression such as pow(2,3) is called a(n) ____________________. A. Function declaration B. function call C. Function initialization D. None of the above

B. function call

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; A. 1565.683 85.8000 123.98 B. 1565.683 85.8000 123.98 C. 1565.683 85.7800 123.98 D. 1565.683 85.780 123.980

C. 1565.683 85.7800 123.98

The get function presented in this chapter only reads values of type _____________. A. double B. integer C. char D. None of the above

C. char

Suppose that xis an int variable and y is a double variable. The input is: 10.5 20.7 Choose the values after the following statement executes: cin>> x >> y;. A. x = 10, y = 20 B. x = 10, y = 20.0 C. x = 10, y = 20.7 D. x = 10, y = 0.5

D. x = 10, y = 0.5

ignore function

Discards a portion of the input

The manipulator setwformats the output of an expression in a specific number of columns; the default output is left-justified. True or False?

False

putback function

Places previous character extracted by the get function from an input stream back to that stream

peek function

Returns next character from the input stream. Does not remove the character from that stream

Function

Set of instructions, when activated it accomplishes a task

______________ forces output to show the decimal point and trailing zeros.

showpoint


Kaugnay na mga set ng pag-aaral

Network - Wireless Practice Questions 2

View Set

Ch. 4-Classification & Assessment of Abnormal Behavior

View Set

Attitudes Influence Behavior and Behavior Influences Attitude

View Set

Civics Who Influenced the Founding Fathers

View Set

Aerobic training adaptations (#5)

View Set