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
A Windows user contacted the help desk with a problem that requires the technician to connect to the remote computer using Remot
djverab [1.8K]

Answer:

RDP port 3389 .

Explanation:

A Windows user has informed the helpdesk with such an issue that requires the operator to link to the remote server through Remote Assistance to access the user's screen with a very comprehensive and ambiguous error message. Almost any attempt made by the operator to link to the remote access concludes in a message that says that the connection has been denied. To make this link, the following protocol and the port number combinations must be enabled on the firewall of the remote connection.

6 0
3 years ago
A newspaper runs stories that suggest that most people in the country support cutting taxes. After reading the stories, people w
Nataliya [291]

Answer:

Spiral of silence

Explanation:

The spiral of silence theory states that people remain silent regarding a topic when they feel that their views are in opposition with the rest of the majority.

As stated in the question, the newspaper's stories suggest that majority of the people support cutting taxes, this leads people who supoort raising taxes to not air their opinions because they think that everyone else supports cutting taxes like the papers say.

5 0
3 years ago
Read 2 more answers
HELP ASAP
joja [24]
Dkydylfiyfuofoyfuofou
7 0
2 years ago
Which keys can be pressed to change the cuboid/frame selector color on remotasks lidar course
Dmitry_Shevchenko [17]

Answer:

c h b l

color palette and a lightbulb

5 0
3 years ago
Someone help me
valkas [14]

The program is an illustration of loops.

Loops are used to perform repetitive and iterative operations.

The program in C++ where comments are used to explain each line is as follows:

#include <iostream>

using namespace std;

int main(){

   //This declares and initializes all variables

   string star = "*", blank = " ", temp;

   //The following iteration is repeated 8 times

   for (int i = 1; i <= 8; i++) {

       //The following iteration is repeated 8 times

       for (int j = 1; j <= 8; j++) {

           //This prints stars

           if (j % 2 != 0) {

               cout << star;

           }

           //This prints blanks

           else if (j % 2 == 0) {

               cout << blank;

           }

       }

       //This swaps the stars and the blanks

       temp = star;

       star = blank;

       blank = temp;

       //This prints a new line

       cout << endl;

   }

}

Read more about similar programs at:

brainly.com/question/16240864

5 0
2 years ago
Other questions:
  • A data structure used to bind an authenticated individual to a public key is the definition of ________.
    14·1 answer
  • When paying bills online, a payee is:
    9·1 answer
  • What is cpu????????????????????????????
    12·2 answers
  • Token stories of success and upward mobility (illustrated by Oprah, Ross Perot, and Madonna) reinforce ________ and perpetuate t
    8·1 answer
  • What does the action tool allow you to do in Microsoft power point?
    9·1 answer
  • EXCEL 2016:
    8·2 answers
  • You can use colors, patterns, and borders to enhance the overall appearance of a worksheet and to make it easier to read. One of
    11·1 answer
  • Alan has introduced a new line of scooters on his website and is using a Google Display Ad campaign to promote them. He selects
    8·1 answer
  • What is the HTML tag used to define a block of content?<br> O <br> O class<br> O #id<br> O
    8·2 answers
  • What are input masks most useful for in data validation? moving data from one field to another hiding parts of a value that are
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!