Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MULTIPLE CHOICE : QUESTION 9 Which of the following is a restriction on use of a

ID: 3858462 • Letter: M

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 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<fstream>, using std::fstream; and using std::ios;

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

Explanation / Answer

Question9: option 1.
To use a stream variable as a function parameter you can only use call-by-reference
Explanation: A stream can be an argument to a function. The only restriction is that the function formal parameter must be call-by-reference. A stream parameter cannot be a call-by-value parameter.

Question 12: Option 1
Executed the given code and all the other options appeared in the output except option1.

Question13:
Option 1, 3
These two are the only two ways to end a loop using for end of a file.

Question15: Except Option 3, Everything is not required.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote