Question
MULTIPLE CHOICE : QUESTION 9 Which of the following is a restriction on use of a stream variable (either ifstream or ofstream)? 1) To use
MULTIPLE CHOICE :
QUESTION 9
Which of the following is a restriction on use of a stream variable (either ifstream or ofstream)?
1) To use a stream variable as a function parameter you can only use call-by-reference
2) To use a stream variable as a function parameter you can only use call-by-value
3) To use a stream variable as a function parameter you can use call-by-value or call-by-value
4) A file variable can be used in any way any other variable can be use
QUESTION 12
Which of these lines is NOT produced by the following code, assuming they are correctly implemented in a program? (You may need to fix them, but without altering the output, i.e. fix the double quotes)
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;
1) *123**
2) +123*+123*
3) 123*123*
4) *123 *
QUESTION 13
Which of the following are correct ways to end a loop using a test for end-of-file?
(Two correct answers)
1) inStream.get(next); while(!inStream.eof( )) { cout << next; inStream.get(next); }
2) inStream.get(next) while(!eof(inStream)) { cout << next; inStream.get(next); }
3) while(inStream >> next) cout << next;
4) while(inStream->next) { cout << next; }
QUESTION 15
To open a file for read-write and random access does NOT require
1) #include
2) The stream to be defined using the class fstream. defined in the header file
3) The usual definition of an ofstream or ifstream object
4) The stream to be connected to the physical file object with first argument a C-string containing the physical file name and a second argument, ios::in | ios::outthat specifies that the i/o with the file should be for either reading or writing
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started