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
What difference between plagiarism and fair use?
Alekssandra [29.7K]
Plagiarism is quite a bad thing because if you plagiarize, you are copying and pasting other people's work and using the work as yours (even though you change the sentence structure/ some words, it is still plagiarizing.) Fair use means un-biasness.
7 0
3 years ago
Help! What is this graph and what does it represent?
Lunna [17]

Answer:

Explanation:

how much something had in each month in this graph

7 0
3 years ago
Currently, the users in your company are required to use their IP addresses when connecting to other hosts. Since IP addresses a
Sonja [21]

Answer:

False

Explanation:

Using subnet mask will be helpful, what the subnet mask does is moving the IP address boundary bettween the part that represents a network and the part that represents a host, thus, instructing the operating system which IP addresses are on the local subnet. Then the operating will communicate directly with the other host without using the router. Once this is achieved, memorizing the IP addresses is needless.          

8 0
3 years ago
Which of the following is not a characteristic of a motorcycle?
MrRa [10]

Answer:

the correct answer is A

3 0
3 years ago
The ______________________ denotes the application software and technology that concerns a wide range of topics from the data ma
zhuklara [117]

Answer:

System/application Domain.

Explanation:

System/application domain represents the technology and  software that is tasked to do diverse subjects from the data management to the systems that processes data or information.

Particular application domain has it's own specific virtual address in which the resources for the application domain are present that uses the address space.

8 0
3 years ago
Other questions:
  • Your colleague received an E-mail from a bank that is requesting credit card and PIN number information. Which of the following
    6·1 answer
  • How do you destroy data on hard drive?
    8·2 answers
  • Which one of the following items would you be most likely to keep in a database ?
    8·1 answer
  • What is the difference between primary storage,secondary storage and offline storage what type of storage can be
    6·2 answers
  • Which of the following has allowed computers to have more memory capabilities without making them extremely expensive Virtual me
    9·1 answer
  • PLEASE HELP ME ASAP!!!!
    11·1 answer
  • How do you recognize the brand name of a drug in the package insert?
    15·1 answer
  • Ted has $55.00 in his pocket. Which purchase will he be able to pay for with cash?
    9·2 answers
  • WHAT IS MULTIMEDIA SUPPOSED TO MEAN ???
    15·2 answers
  • To provide for unobtrusive validation, you can install the ____________________ package for unobtrusive validation.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!