Question
In C++ Write a program that asks the user for a file name. Assume the file contains a series of numbers, each written on a
In C++
Write a program that asks the user for a file name. Assume the file contains a series of numbers, each written on a separate line. Your program should read how many numbers there are in the file and make that value the size of your array, create your own file, I will have my own to run on your program. The program should read the contents of the file into an array and then display the following data:
The lowest number in the array
The highest number in the array
The total of the numbers in the array
The average of the numbers in the array
In addition to your main function, your program should have five functions:
Function that reads the numbers from a file and stores them into an array
Function that finds the lowest value in the array and returns that value. There will be a size parameter which is the number of elements in the array.
Function that finds the highest value in the array and returns that value. There will be a size parameter which is the number of elements in the array.
Function that calculates and returns the sum of the values stored in the array.
Function that calculates and returns the average of the values stored in the array.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started