Question: simple c++ code please Question 1: (File I/O with vector of doubles) An input file contains a list of numbers separated by spaces. Write the

 simple c++ code please Question 1: (File I/O with vector of

simple c++ code please

Question 1: (File I/O with vector of doubles) An input file contains a list of numbers separated by spaces. Write the following functions: vector readValues(); void printResults(vector values); The readValues 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 vector to hold the values of type double, call it res. Read values from the file and save them into the vector res. Close the input file Return the vector res 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 call readValues function to read the values from the file and return them into a vector call it values. 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 22.2 1.365 6 9.443 1.232 5.3 4.34 Source.cpp = output.txt + x input.txt 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!