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
Creative Commons Question -- At home, you created a really great digital song, audio jingle, or music track using some software
galina1969 [7]
C. It's honestly up to the user, upload so others can use it or make it so its copyrighted and make some cash :P
6 0
3 years ago
Which of the following terms describes surgery through a small incision in the abdomen?
ra1l [238]
Which of the following terms describes surgery through a small incision in the abdomen? Laparoscopy. Laparoscopy is super done by using a fiber-optic instrument that is inserted through the abdomen. When this type of instrument is used, the incision is small and there are smaller cuts made to the person being operated on. 
4 0
3 years ago
from january 2005 through july 2015, approximately how many electronic data records in the United States were breached, exposing
Brums [2.3K]
From January 2005 through July 2017, approximately 853 million electronic data records in the US were breached.
This allowed the attackers to take control over people's personal data, such as their various credit card numbers, and other important data, as well as their addresses, etc. The cyber police, as well as the regular police have been working hard to stop this from happening, but the hackers are very strong and smart.
4 0
3 years ago
What information can be determined from a device's MAC address?​
rewona [7]

Answer:

I believe it is the NIC manufacturer and the serial number of the NIC

Explanation:

5 0
3 years ago
A method for selecting multiple lines of text is to _______. select one:
Aliun [14]
I would probably say B even though the other methods might work as well
5 0
3 years ago
Other questions:
  • Write a method so that the main() code below can be replaced by the simpler code that calls method mphandminutestomiles(). origi
    14·2 answers
  • Which of the following is true regarding a class and interface types? Group of answer choices You can convert from a class type
    9·1 answer
  • ______ is a disadvantage of EDI.
    8·1 answer
  • Union Carbide accident safety policies and procedures were not followed was due to
    14·1 answer
  • Create a class named Invoicing that includes three overloaded computeInvoice() methods for a book store: see pages 196 for examp
    7·1 answer
  • Where does the list of incoming mail appear in gmail
    13·2 answers
  • Write a Java program that creates a two-dimensional array of type integer of size x by y (x and y must be entered by the user).
    7·1 answer
  • How do I get the bot token for discord? (scripting etc)
    5·1 answer
  • Write pseudocode for the question below:
    15·1 answer
  • Using range(1,101), make two list, one containing all even numbers and other containing all odd numbers. How can I do this on Py
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!