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
Olivia is an amputee who wears a prosthetic right hand. Which technology would most help her operate a computer?
satela [25.4K]
Nerve interface is technology that allows amputees to use thoughts to move prosthetics
3 0
2 years ago
Which of the following correctly describes the syntax of an If statement?
Ber [7]

if(Expression to be tested) {

code to execute

} else if(Expression to be tested) {

code to execute

}


you can have as many else ifs as you want. But that's what it looks like.

8 0
4 years ago
Im trying to call the keys in a dictionary I have called "planet_dict". in order for them to be included in the for loop, the va
zavuch27 [327]

You can do something like this. My code iterates through the dictionary keys and then we use that key to get a value. We check if the value is between 273 and 373 and if it is, it's a water planet. My code is just a general idea of what to do. Instead of printing, you could add the key to a list and then print the contents of the list.

4 0
3 years ago
Carl knows that water moves through different kinds of soil at different rates. How easily water moves through a soil is known a
Serggg [28]

Answer:

To get the same same results from all pots "amount of water should be same" for all pots.

Explanation:

As Carl want to measure and compare the amount of water that flows in pot in one minute from all all pots. He should keep the amount of water constant for all pots to get the desired results.

6 0
3 years ago
If a class's only constructor requires an argument, you must provide an argument for every ____ of the class that you create.1.
Naddik [55]

Answer:

The answer is "Option 1"

Explanation:

In oops(object-oriented programming language) an object is an example of a specific class or subclass with methods or processes of the class itself and variables for data. When we create an object of the class the default constructor is automatically executed. and other options are not correct that an be described as follows:

  • In option 2, Type is used in data type. It is an attribute, that tells the user or programmer what kind of data value they store. for example string, numeric, and floating-point value.
  • In option 3, Parameter is used in the method for passing a value in function and calculate some values.
  • In option 4, A method is also known as a procedure, that associate with a message and an object.

8 0
3 years ago
Other questions:
  • If the output piston in a car hoist was replaced by a piston of twice the area what would happen to the output force of this sys
    13·1 answer
  • To create an identical version of a slide you would click
    6·2 answers
  • Write a class named Car that has the following data attributes: • _ _year_model (for the car’s year model) • _ _make (for the ma
    15·1 answer
  • What allows windows to quickly be resized by clicking the title bar of the window and dragging it to the top, sides, or middle o
    9·1 answer
  • What are the basic components of a Production System?
    6·1 answer
  • HELP WILL GIVE BRAINIEST IF YOU HELP ME.....
    8·2 answers
  • In a company you are in charge of system maintainance. Justify with 5 reasons why your role is key
    6·1 answer
  • Patient letters created from __________ use structured data and do not require a large amount of typing from the medical assista
    10·2 answers
  • Why would a team choose to employ a zone defense over a person to person defense?
    8·1 answer
  • Step of opening browser on computer​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!