In: Computer Science
You are required to write an interactive program that prompts the user for seven (7) real numbers and performs the following tasks:
Program requirements:
- The program must contain at least five functions using necessary parameters. These functions should read the data, perform the above tasks, and print the results.
- The program must be fully documented.
- You must submit a properly labeled output. .
- Test your program for different values using real numbers.
Please submit with through comments & spacings/indentations from the source code.
#include <iostream>
using namespace std;
void read_array(float arr[])
{
for(int i=0;i<7;i++)
cin>>arr[i];
}
void print_array(float arr[])
{
for(int i=0;i<7;i++)
cout<<arr[i]<<" ";
}
float compute_sum(float arr[])
{
float sum=0;
for(int i=0;i<7;i++)
sum=sum+arr[i];
return sum;
}
float find_average(float arr[])
{
float sum=0;
for(int i=0;i<7;i++)
sum=sum+arr[i];
return sum/7;
}
float find_min(float arr[])
{
float min;
min=arr[0];
for(int i=1;i<7;i++)
if(arr[i]<min)
min=arr[i];
return min;
}
int main()
{
float arr[7],sum,average,small;
cout<<"Enter seven real numbers : "<<endl;
read_array(arr);
cout<<"THE CONTENTS OF ARRAY:"<<endl;
print_array(arr);
sum=compute_sum(arr);
cout<<"\nSum = "<<sum<<endl;
average=find_average(arr);
cout<<"Average = "<<average<<endl;
small=find_min(arr);
cout<<"Smallest = "<<small<<endl;
return 0;
}//end main
input Enter seven real numbers : 4.3 3.5 6.7 8.9 2.1 3.2 6.7 THE CONTENTS OF ARRAY: 4.3 3.5 6.7 8.9 2.1 3.2 6.7 Sum =35.4 Average =5.05714 Smallest = 2.1 . Program finished with exit code 0 Press ENTER to exit console.