Modify arrtemp.cpp (below) by removing the pre-assignment of the data for each array and by adding five new function templates. (WARNING: Make sure to include the line template before each function template)
1. Allow the user to enter the array data from the keyboard.
2. Print the AVERAGE of the array with the two largest values excluded from the average calculation.
3. Sort the array data in ASCENDING order.
4. Save the array data to a text file.
5. Retrieve the array data from the text file.
Output should include the AVERAGE of each numeric array along with all three arrays being printed out in ASCENDING order twice: Once BEFORE the text file is saved and once AFTER the array is retrieved from the text file.
Each Array should be saved to a separate text file.
#include <iostream>
using namespace std;
//function template to print an array
//works for multiple data types
template <class T>
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];
float b[n2];
char c[n3];
cout << "Enter the integer array:" << endl;
for (int i = 0; i < n1; i++)
cin >> a[i];
cout << "Enter the float array:" << endl;
for (int i = 0; i < n2; i++)
cin >> b[i];
cout << "Enter the string:" << endl;
cin >> c;
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;
}
/*
Output:
Enter the integer array:
2 4 6 8 10
Enter the float array:
1.1 2.2 3.3 4.4 5.5 6.6 7.7
Enter the string:
HELLO
The integer array:
2 4 6 8 10
The float array:
1.1 2.2 3.3 4.4 5.5 6.6 7.7
The string is:
H E L L O
*/