[Page 804 (continued)]|
Answer each of the following:
Input/output in C++ occurs as ____________ of bytes.
The stream manipulators that format justification are_________, _________ and _______.
Member function _________ can be used to set and reset format state.
Most C++ programs that do I/O should include the _________ header file that contains the declarations required for all stream-I/O operations.
When using parameterized manipulators, the header file ____________ must be included.
Header file __________ contains the declarations required for user-controlled file processing.
The ostream member function ___________ is used to perform unformatted output.
Input operations are supported by class __________.
Outputs to the standard error stream are directed to either the ___________ or the ___________ stream object.
Output operations are supported by class ___________.
The symbol for the stream insertion operator is ____________.
The four objects that correspond to the standard devices on the system include _________, _________, __________ and ___________.
The symbol for the stream extraction operator is __________.
The stream manipulators ___________, __________ and ___________ specify that integers should be displayed in octal, hexadecimal and decimal formats, respectively.
When used, the _________ stream manipulator causes positive numbers to display with a plus sign.
State whether the following are true or false. If the answer is false, explain why.
The stream member function flags with a long argument sets the flags state variable to its argument and returns its previous value.
The stream insertion operator << and the stream-extraction operator >> are overloaded to handle all standard data typesincluding strings and memory addresses (stream-insertion only)and all user-defined data types.
The stream member function flags with no arguments resets the stream's format state.
The stream extraction operator >> can be overloaded with an operator function that takes an istream reference and a reference to a user-defined type as arguments and returns an istream reference.
The stream insertion operator << can be overloaded with an operator function that takes an istream reference and a reference to a user-defined type as arguments and returns an istream reference.
Input with the stream extraction operator >> always skips leading white-space characters in the input stream, by default.
The stream member function rdstate returns the current state of the stream.
The cout stream normally is connected to the display screen.
The stream member function good returns TRue if the bad, fail and eof member functions all return false.
The cin stream normally is connected to the display screen.
If a nonrecoverable error occurs during a stream operation, the bad member function will return TRue.
Output to cerr is unbuffered and output to clog is buffered.
Stream manipulator showpoint forces floating-point values to print with the default six digits of precision unless the precision value has been changed, in which case floating-point values print with the specified precision.
The ostream member function put outputs the specified number of characters.
The stream manipulators dec, oct and hex affect only the next integer output operation.
By default, memory addresses are displayed as long integers.
For each of the following, write a single statement that performs the indicated task.
Output the string "Enter your name: ".
Use a stream manipulator that causes the exponent in scientific notation and the letters in hexadecimal values to print in capital letters.
Output the address of the variable myString of type char *.
Use a stream manipulator to ensure floating-point values print in scientific notation.
Output the address in variable integerPtr of type int *.
Use a stream manipulator such that, when integer values are output, the integer base for octal and hexadecimal values is displayed.
Output the value pointed to by floatPtr of type float *.
Use a stream member function to set the fill character to '*' for printing in field widths larger than the values being output. Write a separate statement to do this with a stream manipulator.
Output the characters '0' and 'K' in one statement with ostream function put.
Get the value of the next character in the input stream without extracting it from the stream.
Input a single character into variable charValue of type char, using the istream member function get in two different ways.
Input and discard the next six characters in the input stream.
Use istream member function read to input 50 characters into char array line.
Read 10 characters into character array name. Stop reading characters if the '.' delimiter is encountered. Do not remove the delimiter from the input stream. Write another statement that performs this task and removes the delimiter from the input.
Use the istream member function gcount to determine the number of characters input into character array line by the last call to istream member function read, and output that number of characters, using ostream member function write.
Output the following values: 124, 18.376, 'Z', 1000000 and "String".
Print the current precision setting, using a member function of object cout.
Input an integer value into int variable months and a floating-point value into float variable percentageRate.
Print 1.92, 1.925 and 1.9258 separated by tabs and with 3 digits of precision, using a manipulator.
Print integer 100 in octal, hexadecimal and decimal, using stream manipulators.
Print integer 100 in decimal, octal and hexadecimal, using a stream manipulator to change the base.
Print 1234 right justified in a 10-digit field.
Read characters into character array line until the character 'z' is encountered, up to a limit of 20 characters (including a terminating null character). Do not extract the delimiter character from the stream.
Use integer variables x and y to specify the field width and precision used to display the double value 87.4573, and display the value.
Identify the error in each of the following statements and explain how to correct it.
cout << "Value of x <= y is: " << x <= y;
The following statement should print the integer value of 'c'.
cout << ""A string in quotes"";
For each of the following, show the output.
cout << "12345" << endl;
cout.width( 5 );
cout.fill( '*' );
cout << 123 << endl << 123;
cout << setw( 10 ) << setfill( '$' ) << 10000;
cout << setw( 8 ) << setprecision( 3 ) << 1024.987654;
cout << showbase << oct << 99 << endl << hex << 99;
cout << 100000 << endl << showpos << 100000;
cout << setw( 10 ) << setprecision( 2 ) << scientific << 444.93738;