Answer:
#include<iostream>
using namespace std;
void stats(double [],int);
int main()
{
int totalElements,i;
cout<<"Enter total elements:"<<endl;
cin>>totalElements;
double array[totalElements];
cout<<"Enter the elements in array:"<<endl;
for(i=0;i<totalElements;i++)
cin>>array[i];
stats(array,totalElements);
}
void stats(double array[],int totalElements)
{
int i;
double minimum,maximum;
double Sum=0.0,average=0.0;
minimum=array[0],maximum=array[0];
for(i=0;i<totalElements;i++)
{
if(array[i]>maximum)
maximum=array[i];
if(array[i]<minimum)
minimum=array[i];
Sum+=array[i];
}
average=Sum/totalElements;
cout<<"Test: ";
for(i=0;i<totalElements;i++)
cout << fixed << setprecision(2) <<array[i]<<" ";
cout<<endl;
cout <<"minimum:"<< fixed << setprecision(2) <<minimum<<endl;
cout <<"maximum:"<< fixed << setprecision(2) <<maximum<<endl;
cout <<"average:"<< fixed << setprecision(2) <<average<<endl;
}
Explanation: