Question
In C++ (Sum, average, and sort in ascending order and replace) Suppose that a text file numbers.txt (please download the file by clicking the link)
In C++
(Sum, average, and sort in ascending order and replace) Suppose that a text file numbers.txt (please download the file by clicking the link) contains thousands of integers. Write a program that reads the integers from the file, and displays their sum, average, and sort the integers in ascending order, and writes the sorted numbers in a file.
Please use a function to sort the integers in ascending order, such as void selection_sort(vector& v);
Write a program that
1) prompts the user to enter the file name, and display the sum, average, and the number of integers contained in the file,
2) sort the integers in ascending order,
3) and write the sorted integers in the file.
Here are the sample runs:
Please enter the file name: numbers.txt
The number of integers: 4856
The sum of integers: 3998660
The average of integers: 823
The sorted number are stored in sorted_numbers.txt
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