1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Luba_88 [7]
3 years ago
8

Write a function stats that takes an array and the number of elements in the array. Then, it computes and prints the minimum val

ue, maximum value, and the average value of all the values in the array. The output should be formatted with a two-digit precision. The function name: stats The function parameters (in this order): an array, double The number of elements in the array, int The function should not return anything.
Computers and Technology
1 answer:
BaLLatris [955]3 years ago
6 0

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:

  • Loop through the total elements to get the input from user and call the stats function.
  • In the stats function check whether a number is maximum, minimum or average.
  • Calculate the average by finding the sum of all the numbers in array  and dividing it by total numbers.
  • Finally display the results.

You might be interested in
How would you maximize the use of outsourced programmers?
Lerok [7]

Answer:

the answer is: release them when the project is complete

Explanation:

8 0
2 years ago
A search engine company needs to do a significant amount of computation every time it recompiles its index. For this task, the c
romanna [79]

Answer:

See attached pictures for detailed answer.

Explanation:

See attached pictures for explanation.

5 0
2 years ago
You can apply the Bold font style by pressing the ____ keyboard shortcut keys.
Free_Kalibri [48]
CTRL+B when you hover your mouse over it on powerpoint it comes up saying that
8 0
3 years ago
Read 2 more answers
The illustration shows different types of text language. Thought and speech bubbles labeled as follows: p l s, A S A P (all caps
Otrada [13]

Answer:

the answer to your question would be keeping content appropriate

Explanation: hope i helped <3 : )

8 0
2 years ago
Read 2 more answers
What do you ensure when you set up goals and objectives for your website design?
Rina8888 [55]

i need the answer too

here is the options tho

A.  the website has structure and direction

B.  the website project has a set deadline

C.  the website has targets to achieve

D.  the objectives provide estimation of cost

4 0
2 years ago
Read 2 more answers
Other questions:
  • Which of these jobs would be most appropriate for someone who majors in computer engineering? I need the answer ASAP Helping com
    14·2 answers
  • It is safe to stand on the top step of a ladder provided it is braced property
    10·1 answer
  • A collection of computers and other hardware devices that are connected together to share hardware, software, and data, as well
    15·1 answer
  • I stole you pokemon cards :o
    6·2 answers
  • Suppose there are 69 packets entering a queue at the same time. Each packet is of size 7 MiB. The link transmission rate is 1.7
    9·1 answer
  • It is important for security practitioners to take into consideration the __________ element when devising password security pol
    15·1 answer
  • Why can’t I “change the country” on settings??<br> (In this app)
    13·1 answer
  • You are asked to check your company’s configurations to determine if any filters should be built to stop certain ICMPv6 traffic.
    9·1 answer
  • When evaluating platforms, what is the key factor in ensuring a platform addresses an organization's needs?
    8·1 answer
  • An end-user license agreement protects _____.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!