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

What is the next step in using a file, after the file has been declared with the

ID: 3842976 • Letter: W

Question

What is the next step in using a file, after the file has been declared with the following? ofstream AnsFile; A. You use the file to input a variable. B. You use the file by outputting a value to it. C. You search for a file named AnsFile. D. You open the file, and associate it with a specific file name. Which of the following statements correctly opens the output file object AnsFile to store answers into file myanswers.txt? A. AnsFile.open("myanswers.txt"); B. open.AnsFile("myanswers.txt"); C. open.AnsFile(myanswers.txt); D. AnsFile.open(myanswers.txt): which statement will properly store the number from variable value into the output file object AnsFile? A. AnsFile value; D. value = read.Myinput(); Which of the following statements will close the output file object AnsFile from the previous question(20)? A close.AnsFile; B. "myanswer.txt", close; C AnsFile.close(); D. AnsFile.close ("myanswer.txt"); Which repetition constructs will properly repeat the loop body while not at the end-of-file for input file object Datafile A. while (! Data file) B. while (! eof()) C. whle (! Datafile.eof()) D. while(! eof.DateFile()) The argument and parameters A. must agree m number, and identifier name B. must agree in data type and identifier name. C. must agree in number and order In the following function prototype: int fun 1|double& Num1, double& Num 2); A. Function fun1 can modify the arguments passed to both Num1 and Num2 B Function fun1 cannot modify the arguments passed to Num1 and Num2 C. Function fun1 can only modify the argument passed to Num1 D function fun1 can only modify the argument passed to Num2 Which library contains the function used to seed the random number generator? A Cstdlib B ctime C crandom D. cmath Which of the following statements property invokes the random number generator storing the resulting random number into myNumber A myNumber = lessthanorequalto rand(); B. myNumber = lessthanorequalto rand(time(0)); C. myNumber = rand(); D. None of the THESE.

Explanation / Answer

19. Answer is D.

You have just created a new file object with necessary methods on it. But you have not provided it with any filename to associae with. So you have to do that first to be able to run any methods on it.

20. Answer is A

Since you run methods on the object by doing:

<object_name>.<method_name>("<file_name>");

All other options lack one thing or the other.

21. Answer is A

Just like cout, you do it with << operator like so:

<output_file_object> << variableName;

Since both cout and filestream both are inherited from related objects of iostream.

22. Answer is a A

<input_file_object> >> variableName;

23. Answer is C

you can close a file by doing <file_object>.close();

24. The answer is C

you can do:

while (! fileObject.eof())

to iterate to the end of the file. fileObject.eof() returns true if he EOF in a file is hit.

25. Answer is C

They must have same type and order.

26. Answer is A

It can modify any value that has been passed to it, due to sending in of addresss using & operator now the function can totally manipulate the data at given memory location.

27. Answer is A

Its not typed in properly it is actually cstdlib, observe that the first letter is not capital.

28. The answer is B

srand(time(0)), without this there will not be a proper initialization and the actual randomness comes from this.

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