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

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 Programming Questions!