Question: C++ Programming Modify arrtemp.cpp by removing the preassignment of the data for each array and by adding five new function templates. The first new function

C++ Programming

Modify arrtemp.cpp by removing the preassignment of the data for each array and by adding five new function templates. The first new function template should allow the user to enter the array smallest and largest values excluded from the average calculation. The third new function template should sort the array data array in descending order. The fourth new function template should save the array data to a text file. The fifth new function template should retrieve the array data from the text file. Output should include the average of each numerical array with the smallest and largest values excluded and all three arrays being printed out in descending order twice, once before the text file is saved and once after the array is retrieved from the text file. (Warning - make sure to include the line 'template ' before each function template.) Each array should be saved to a separate text file. You will need to submit the text files with the program.

arrtemp.cpp:

#include using namespace std;

template void printarray (T *a, const int n) { for (int i = 0; i < n; i++) cout << a[i] << " "; cout << endl; }

int main() { const int n1 = 5, n2 = 7, n3 = 6; int a[n1] = {2, 4, 6, 8, 10}; float b[n2] = {1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7}; char c[n3] = "HELLO";

cout <<"the integer array" << endl; printarray(a, n1);

cout <<"the float array" << endl; printarray(b,n2);

cout <<"the string is" << endl; printarray(c,n3); return 0; }

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!