Question: C++ ONLY PLEASE Question 1: (File I/O with 1D dynamic arrays) An input file is formatted as follows: the first number is the number n

C++ ONLY PLEASE Question 1: (File I/O with 1D dynamic arrays) AnC++ ONLY PLEASE

Question 1: (File I/O with 1D dynamic arrays) An input file is formatted as follows: the first number is the number n of values in the text file, followed by n numerical values. Write the following functions: double* readArray(int &size); void printResults(double *arrint size): The readArray function should do the following steps: Open the input file "input.txt" and make sure it is opened successfully, if not print an error message and exit the program. Declare a pointer of type double call it arr. Read the size of the array from the input file, save it in the pass-by-reference size variable Allocate memory for art of the size that you read from the file Read values from the file and save them into the arr. Close the input file Return art to the caller. Th printResults function should do the following steps: Open an output file called output.txt Declare and initialize variables for min max and sum, make sure not to use a constant value (like 0) to initialize the min and max. Calculate min, max and sum. Print min max and sum to the output file. . . . Write a C++ program that declare a pointer of type double A and an int size, then call seadArray, function to initialize the Array A and the size. Then call the printResults. function to print the results an output file named output.txt. Sample input and output files are given below: output.txt input.txt + x Source.cpp 7 22.2 1.365 6 9.443 1.232 5.3 4.34 output.txt + X input.txt Source.cpp Min = 1.232 Max = 22.2 Sum 49.88

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!