Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedsimple 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago