A program reads data from a file called inputFile.dat and, after doing some calc
ID: 3664301 • Letter: A
Question
A program reads data from a file called inputFile.dat and, after doing some calclations, writes the results to a file called outFile.dat. Answer the following questions: a. After the program executes, what are the contents of the file inputFile.dat? b. After the program executes, what are the contents of the file outFile.dat if this was empty before the program executed? c. After the program executes, what are the contents of the file outFile.dat if this file contained 100 numbers before the program executed? d. What would happen if the file outFile.dat did not exist before the program executed?
Explanation / Answer
a) After the program executes, the contents of the file inputFile.dat are the same. The program just reads its contents and does not alter it.
b) After the program executes, the contents of the file outFile.dat is the results computed by the program.
c) If outFile.dat initially contained 100 numbers, the results produced by the program are overwritten over initial 100 numbers thereby replacing them. Therefore, we lose these 100 numbers.
d) If the file outFile.dat did not exits before the program executed, the program creates a file outFile.dat and writes its results to it.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.