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

simple c++ URGENT Question 1: (File I/O with 1D dynamic arrays) Ansimple c++ URGENT

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 *armeint 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 arr 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 arr 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 readArray function to initialize the Array A and the size. Then call the printResults function to print the results an output file named output.txt

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!