Respuesta :
Answer:
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
void showValues(const int a[], int size);
void fillArray(int a[], int size, int low, int high);
int maximum(const int a[], int size);
int minimum(const int a[], int size);
double average(const int a[], int size);
int main(){
int size = 10;
int low,high;
cout<<"Low: ";
cin>>low;
cout<<"High: ";
cin>>high;
if(high<low){
high = high + low;
low = high - low;
high = high - low;
}
int a[size];
//Enter your details here e.g. cout<<"Name: Programmer XYZ"
fillArray(a, size, low, high);
showValues(a, size);
cout<<"Maximum: "<<maximum(a, size)<<endl;
cout<<"Minimum: "<<minimum(a, size)<<endl;
cout<<"Average: "<<average(a, size)<<endl;
}
void fillArray(int a[], int size, int low, int high){
unsigned seed = time(0);
srand(seed);
for (int j = 0;j<size;j++){
a[j]=low + rand() % (( high+ 1 ) - low);
}
}
void showValues(const int a[], int size){
for(int i =0;i<size;i++){
cout<<a[i]<<" ";
}
cout<<endl;
}
int maximum(const int a[], int size){
int max = a[0];
for(int i =1;i<size;i++){
if(a[i]>max){
max = a[i];
}
}
return max;
}
int minimum(const int a[], int size){
int min = a[0];
for(int i =1;i<size;i++){
if(a[i]<min){
min = a[i];
}
}
return min;
}
double average(const int a[], int size){
double total = a[0];
for(int i =1;i<size;i++){
total+=a[i];
}
return total/size;
}
Explanation:
This solution is implemented in C++. The source code is a bit length. So, I added the explanation as an attachment of the source file where I used comments to explain some lines.