Exam 12: Streams and File IO
Exam 1: C++ Basics37 Questions
Exam 2: Flow of Control33 Questions
Exam 3: Function Basics30 Questions
Exam 4: Parameters and Overloading31 Questions
Exam 5: Arrays32 Questions
Exam 6: Structures and Classes37 Questions
Exam 7: Constructors and Other Tools32 Questions
Exam 8: Operator Overloading,friends,and References31 Questions
Exam 9: Strings37 Questions
Exam 10: Pointers and Dynamic Arrays29 Questions
Exam 11: Separate Compilation and Namespaces35 Questions
Exam 12: Streams and File IO43 Questions
Exam 13: Recursion40 Questions
Exam 14: Inheritance30 Questions
Exam 15: Polymorphism and Virtual Functions34 Questions
Exam 16: Templates27 Questions
Exam 17: Linked Data Structures30 Questions
Exam 18: Exception Handling29 Questions
Exam 19: Standard Template Library46 Questions
Exam 20: Patterns and Uml22 Questions
Select questions type
Assume that your program opens a file stream,has a file connected,and writes to the file.What changes need to be made to make your program write to the screen? (There will be stuff you need to delete and stuff that you need to change. )
(Essay)
4.9/5
(32)
What output is produced by the following code,assuming these lines of code are embedded in a correct program?
cout << "*" << setw(5)<< 123;
cout.setf(ios::left);
cout << "*" << setw(5)<< 123;
cout.setf(ios::right);
cout << "*" << setw(5)<< 123 << "*" << endl;
(Essay)
4.7/5
(43)
The flush member function copies the file buffer to the file on the file medium (disk,tape,etc).
(True/False)
4.8/5
(42)
You have to #include <iomanip> as well as #include <iostream> when you use a line of code such as
cout << setw(8)<< 123456 << endl;
but not have to #include <iomanip> when you do the exact equivalent thing in
cout.width(8);
cout << 123456 << endl;
Why is this?
(Essay)
4.8/5
(29)
If the output is too wide for the width specified in a setw manipulator or a call to the width member function,then the output is lost.
(True/False)
4.8/5
(42)
What output will be produced when the following code is executed? (Assume these lines are embedded in complete,correct programs,with proper #include directives. )
cout << "*";
cout.width(5);
cout << 123
<< "*" << 123 << "*" << endl;
cout << setw(5)<< 123 << "*" << 123 << "*" << endl;
(Essay)
4.8/5
(40)
An istream object is already an ifstream object with some extra,added features.
(True/False)
4.8/5
(25)
Write a program that prompts for an input file name,receives the input file name in a C-string.The program should check for errors opening a file.It is not necessary for the program to do anything other than open the file.
(Essay)
4.9/5
(42)
Write a loop that will read from the current position in a file up to the end of the current line,and send this output to the screen.You may assume that any variables you need are declared,including file variables,and that any needed files have been successfully opened.
(Essay)
4.8/5
(39)
There are three calls to member functions of ostream object cout that set the format of stream output so that the format of the output is in fixed point,a decimal point always shows,and there are two places of decimals after the decimal point.Give these statements along with the necessary #include and using statements.
(Essay)
4.7/5
(37)
When you call the setf function on an output stream,the effect is only until the next output.
(True/False)
4.9/5
(45)
Assume you have opened and connected stream variables fileIn and fileOut.Assume further that you have finished with the input and output files.Write the statements necessary to close these files.
(Essay)
4.8/5
(41)
You get the manipulators endl and member functions setf and precision with the iostream header,but you have to include the iomanip header to get the manipulators setw and setprecision..
(True/False)
4.9/5
(34)
When you write
ifstream inStream;
inStream.open("infile.dat");
the file,infile.dat must be located in the directory where the program is being run.
(True/False)
4.8/5
(38)
When you use the open member function to tie a file name to a file stream,the file name is called the external file name,and the program refers to the file by the stream name.
(True/False)
4.8/5
(41)
You are writing a program.Give the necessary statements to open a file and to confirm that the file has been successfully opened for writing.Important: Why bother to test?
(Essay)
5.0/5
(39)
Setting the width of output with the manipulator setw is different from setting the width with the width member function.
(True/False)
4.9/5
(35)
An output stream is a stream of data flowing from your program,to a file,a device of some sort such as the screen.
(True/False)
4.8/5
(42)
What output is produced by the following code,assuming these lines of code are embedded in a correct program?
cout << "*" << setw(5)<< 123 << "*"
<< 123 << "*" << endl;
cout.setf(ios::showpos);
cout << "*" << setw(5)<< 123 << "*"
<< 123 << "*" << endl;
cout.unsetf(ios::showpos):
cout.setf(ios::left);
cout << "*" << setw(5)<< 123 << "*"
<< setw(5)<< 123 << "*" << endl;
(Essay)
4.8/5
(32)
Showing 21 - 40 of 43
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)