Ch. 3 C++ Programming Eighth Edition by D.S. Malik

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

What is an output stream?

A stream from a computer to a destination.

What is an input stream?

A stream from a source to a computer.

What is a Stream in C++?

An infinite sequence of characters from a source to a destination.

True or False: The statement cin>>length; and length>>cin; are equivelent.

FALSE

True or False: To use the manipulators fixed and showpoint, the program does not require the inclusion of the header file iomanip.

FALSE.

True or False: The statement cin>>right; sets the input of only the next variable right-justified

FALSE. The manipulator right is used to display the result on the standard output device in right-justified format. it cannot be used with the input stream cin

True or False: When the input stream enters the fail state, the program terminates with an error message.

FALSE. When it enters fail state, it ignores the rest of the input. The program continues to execute with the available values.

True or False: The statement cin.get(ch); inputs the next non-whitespace character into the variable ch.

FALSE. the function get reads the input stream, including all whitespaces.

True or False: When the statement cin >> num1 >> num2; executes, then after inputting a number into the variable num1 the program skips all trailing whitespace characters.

False. It will read the stream of characters from the input and then skip all the whitespaces that are present

True or False: Suppose pay is a variable of type double. The statement cin>>pay; requires the input of a decimal number.

False. double is waiting for a numeric value to be inputted, but the numeric value can be an integer or a decimal

What does the manipulator setw do?

It formats the output of an expression in a specific number of columns, the default output is right-justified

What does the manipulator fixed do?

It outputs the floating-point numbers in the fixed decimal format.

How do you restore the input stream to a working state?

Once an input failure has occurred red, you use the function clear to restore the input stream to a working state.

True or False: An output stream is a sequence of characters from a computer to an output device.

TRUE

True or Fasle: to use cin and cout in a program, the program must include the header file iostream.

TRUE

True or False: When inputting data into a variable, the operator >> skips all leading whitespace characters.

TRUE.

What is the function get used for? does it skip whitespaces?

The function get is used to read data on a character by character basis and does not skip any whitespace characters.

True or False: To use the predefined function sqrt in a program, the program must include the header file cmath.

True

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

True.

What is a stream insertion operator?

When the binary operator << is used with an output stream object, such as cout, it is called the stream insertion operator.

What is a stream extraction operator?

When the binary operator >> is used with an input stream object, such a cin, it is called the stream extraction operator.

When is the output expression right-justified? How do you left-justify the output?

When the number of columns specified in the setw manipulator exceeds the number of columns required by the next expression. to left-justify the output, you'll use the manipulator left

How does the input stream enter the fail state?

by trying to read invalid data into a variable

What does cin stand for? is it an input or output stream object? What device is it typically connected to?

cin stands for common input. it is an input stream object. Input device is usually a keyboard.

What does cout stand for? is it an input or output stream object? What device is it typically connected to?

cout stands for common output. it is an output stream object. The output device is usually a monitor screen.

How do you close a file as indicated by the ifstream variable inFile and ofstream variable outFile?

inFile.close() \\no quotation marks on the inside brackets outFile.close()\\no quotation marks on the inside brackets

What header file must be used in order to use the manipulators setprecision, setw, and setfill?

iomanip

What header file must be used to use cin and cout?

iostream

What header file must be used to use the stream functions get, ignore, putback, peek, clear, and unsetf for standard I/O?

iostream

What does the manipulator setprecision do?

it formats the output of the floating-point numbers to a specified number of decimal places.

What does the manipulator setfill do?

it is used to fill the unused columns on an output device with a character other than a space.

What does the function putback do?

it puts the last character retrieved by the function get back into the stream.

What does the function peek do?

it returns the next character from the input stream but does not remove the character from the input stream.

In C++, what is ' (single-quote mark)?

its a digit separator.

What does the manipulator showpoint do?

outputs the floating-point numbers with a decimal point and trailing zeros.

What is the function ignore used for?

skip data in a line

What does the header file fstream contain?

the definitions of ifstream and ofstream

What happens if there isn't enough columns specified in the argument of setw that are needed to print the value of the expression?

the output is not truncated and the output of the expression expands to the required number of columns.

Do you have to declare the variables of type ifstream and ofstream? What are the open statements to open input and output files with declared values of inFile and outFile?

yes. You must declare the variables of type ifstream for file input and of type ofstream for file output. inFile.open(" ") outFile.open(" ")


Conjuntos de estudio relacionados

Adaptive Quizzing for Drugs For Mood Disorders

View Set

Cell-cell interactions// Mastering biology

View Set

The Physiology of Breathing- BIO 153

View Set

Chapter 16: The Spine: Exercise and Manipulation Interventions (Kisner and Colby)

View Set

Chapter 21. Managing Patient Care

View Set

EMT - Chapter 30: Abdominal and Genitourinary Injuries

View Set

Written quiz n.4 modules 9, 10, and 11

View Set

9.5 Regulation of Variable Insurance Products

View Set

STAAR Question & Answer Practice

View Set

Stimulants Presentation For In Class Activity

View Set

Bio 151 Chapter 4.1-4.2 Questions

View Set