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
____________________ is like a set of instructions that helps hardware process data into information.
Arte-miy333 [17]

Answer:

Program

Explanation:

Program is like a set of instructions that helps hardware process data into information.

Every hardware needs a program to process data into information.

For example take the example of a data processing software like MS Excel.

You open a spreadsheet and enter some data into your sheet. and then ask the program to do some calculations with this data and give you output results. The spreadsheet software does this processing in the background for you and provides you the results.

Without program a hardware doesn't know what to do with the data. Therefore, a program is like a instruction set that guides the hardware what to do with the data.

Note: The terms software and program are usually used together but there is a difference between software and program

A software is a generalized term and program is more like a specific term.

software can be made up of several different programs which performs many different tasks. On the other hand, a program only carry out a specific task or set of instructions.

3 0
3 years ago
Isabela wants to add an image to her presentation. Which tab should she use?
Tresset [83]

Answer:

I believe its insert

Explanation:

because when u insert an image ur adding it

6 0
4 years ago
Ok so I know this is the most random question to ask on brainly, but does anyone know how to copy on placement in sims 4 for pc?
pochemuha

Answer:

yes i do i will tel you if you put brainlist

Explanation:

3 0
3 years ago
Read 2 more answers
Uso de las redes sociales como el uso de una impresora en casa se satisfacen estás tres etapas
Svetradugi [14.3K]

Question: what question is this?

7 0
3 years ago
4. All executed programs in the windows<br> environment is displayed on<br> the?
nadya68 [22]

All executed programs in the windows environment are displayed on the Windows manger.

<h3>What is a program?</h3>

In Computer programming, a program can be defined as a sequence of instructions that are written in a specific programming language and can be executed or interpreted by a computer.

The programs that are executed in the windows environment by the operating system (OS) of a computer system are generally displayed on the Windows manger and stored in the computer's main memory, which is the random access memory (RAM).

Read more on programs here: brainly.com/question/23275071

4 0
2 years ago
Other questions:
  • How do you stop your questions on here from getting your questions from getting removed?
    5·2 answers
  • What character separates the file extension and the filename?
    13·2 answers
  • What is the command to create a compressed archive(archive1.tar.gz) of files test1 test2and test3.
    5·1 answer
  • Is USA TestPrep a test-taking site that won't let you access other windows without kicking you off?
    13·1 answer
  • Pls help I will give lots of points
    9·1 answer
  • A customer would like you to install a high-end video card suitable for gaming. Your installation and configuration SHOULD inclu
    7·1 answer
  • Dora has inserted a text box into a Word document that she is formatting. Which strategy will not format text boxes? Create a li
    6·2 answers
  • I’ll mark brainlest
    14·2 answers
  • Which of the following was the most significant impact the NEA had on the performing arts industry? W
    15·1 answer
  • What is being done to reduce the python population in florida?.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!