Question: Use C++ language You should assume that there will be an object file named sub.o which implements a function whose prototype is given in the

Use C++ language

Use C++ language You should assume that there will be an objectfile named "sub.o" which implements a function whose prototype is given inthe header file "sub.h". The header file "sub.h" consists of the following

You should assume that there will be an object file named "sub.o" which implements a function whose prototype is given in the header file "sub.h". The header file "sub.h" consists of the following line. int sub(int n, int *A, int *B, int *C); However, you do not know what this function is doing. For your testing purpose, you may produce such a function, e.g., returning the maximum value among the 3n integers in the three arrays. You are also given an ASCII file named "input.txt". The first line of this file contains an integer n. There are n additional lines in the file, where the ith additional line contains three integers x; Y; and Z;. A sample of "input.txt" is the following. 5 2 3 3 4 5 6. 8. 5 9. 9. 10 11 You need to write a driver that does the following Open an input file (for reading) named "input.txt". You program should output an error message and stop, if the file cannot be opened for reading. Write (using "cout" of "printf") to the screen "Input file open". Read the first integer in the file into an integer var named n. Dynamically allocate memory for an array A of size n, an array B of size n, and an array C of size n. Write a sentence to the screen "Memory allocated". Read data from the input file into the arrays, so that A[i 1] = xi, B[i 1] = Y; and C[i 1] = z; for i = 1, 2, .., n. Write to the screen "Data read from input file". Close the input file. Write to the screen "input file closed". Open an output file (for writing) named "output.txt". Write to the screen "Output file open". Write n into the output file (in the first line). Then write A[i], B[i]andC[i] in the next line, for i = 1, 2, ..., n. Write to the screen "Data written to output file". Call the function sub by the command result = sub(n, A, B, C); Write to the screen "Function called". Write the value of result into the output file. Write to the screen "Result written to output file". Close the output file. Write to the screen "Output file closed". Stop. If the function sub" returns the maximum among the 3n array elements, the file "output.txt" corre- sponding to the sample "input.txt" will be: 2 3 4 3 7 10 11 11

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!