Answer: Provided in the explanation segment
Explanation:
Below is the code to carry out this program;
/* C++ program helps prompts user to enter the size of the array. To display the array elements, sorts the data from highest to lowest, print the lowest, highest and average value. */
//main.cpp
//include header files
#include<iostream>
#include<iomanip>
using namespace std;
//function prototypes
void displayArray(int arr[], int size);
void selectionSort(int arr[], int size);
int findMax(int arr[], int size);
int findMin(int arr[], int size);
double findAvg(int arr[], int size) ;
//main function
int main()
{
const int max=50;
int size;
int data[max];
cout<<"Enter # of scores :";
//Read size
cin>>size;
/*Read user data values from user*/
for(int index=0;index<size;index++)
{
cout<<"Score ["<<(index+1)<<"]: ";
cin>>data[index];
}
cout<<"(1) original order"<<endl;
displayArray(data,size);
cout<<"(2) sorted from high to low"<<endl;
selectionSort(data,size);
displayArray(data,size);
cout<<"(3) Highest score : ";
cout<<findMax(data,size)<<endl;
cout<<"(4) Lowest score : ";
cout<<findMin(data,size)<<endl;
cout<<"(5) Lowest scoreAverage score : ";
cout<<findAvg(data,size)<<endl;
//pause program on console output
system("pause");
return 0;
}
/*Function findAvg that takes array and size and returns the average of the array.*/
double findAvg(int arr[], int size)
{
double total=0;
for(int index=0;index<size;index++)
{
total=total+arr[index];
}
return total/size;
}
/*Function that sorts the array from high to low order*/
void selectionSort(int arr[], int size)
{
int n = size;
for (int i = 0; i < n-1; i++)
{
int minIndex = i;
for (int j = i+1; j < n; j++)
if (arr[j] > arr[minIndex])
minIndex = j;
int temp = arr[minIndex];
arr[minIndex] = arr[i];
arr[i] = temp;
}
}
/*Function that display the array values */
void displayArray(int arr[], int size)
{
for(int index=0;index<size;index++)
{
cout<<setw(4)<<arr[index];
}
cout<<endl;
}
/*Function that finds the maximum array elements */
int findMax(int arr[], int size)
{
int max=arr[0];
for(int index=1;index<size;index++)
if(arr[index]>max)
max=arr[index];
return max;
}
/*Function that finds the minimum array elements */
int findMin(int arr[], int size)
{
int min=arr[0];
for(int index=1;index<size;index++)
if(arr[index]<min)
min=arr[index];
return min;
}
cheers i hope this help!!!