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
If your pulse is higher than your Target Heart Rate during exercise, what should you do?
vodomira [7]
If your heart rate exceeds 185 beats per minute during exercise, it is dangerous for you. Your target heart rate zone is the range of heart rate that you should aim for if you want to become physically fit. It is calculated as 60 to 80 percent of your maximum heart rate.
8 0
2 years ago
Read 2 more answers
A software development company wants to reorganize its office so that managers and the Computer Programmers they supervise can b
dimaraw [331]
Perhaps instead of cubicles, desks are organized in an open workspace which promotes collaboration (and makes it easier).
7 0
2 years ago
Read 2 more answers
How are modern computers different from eniac?
Natalka [10]
Modern computers use in side a memory board to store info but back then you would use flappy disks   
8 0
3 years ago
In the bremmer article, the author states that _________ translates into greater risks.
blondinia [14]

Answer:

instability

Explanation:

3 0
1 year ago
The component that allows you to make a paper-based copy of a body of text is the _____.
ANTONII [103]
The correct answer is: Scanner

The scanner is a piece of technology which unlike the printer is an input device which basically scans the top-view of any flat surface (usually paper but is definitely not limited to it) introduced in its effective range using light. The data scanned is then transfered to the Central Processing Unit for futher processing. The processed image can then be outputted and seen on the monitor's display. Once available for printing, the Central Processing Unit will just send the processed image into the printer ad voila, your scanned image is now printed in a piece of paper!

Today, scanners come with printers as a bundle. It is a perfect combination since the printer will just print the image anyway.
5 0
3 years ago
Other questions:
  • Susan bought a new sweater on sale for $28.93.she was charged HST of 13%.find the total amount of her bill including taxes.​
    9·1 answer
  • It is okay to use a dust rag when cleaning the inside of a computer.
    9·2 answers
  • Ansel Adams education and special training
    14·1 answer
  • Pamela finds that she is constantly spelling the word “color” as “colour” when she is typing. Even though this is how the word i
    11·1 answer
  • Should I download RAM on my computer?
    11·2 answers
  • OSHA standards appear in the ___________ and are then broken down into ____________.
    9·1 answer
  • Any material that comes into contact with the body must be __________.
    6·1 answer
  • Which step in the software development life cycle analyzes the scope of work?
    6·1 answer
  • Web résumés allow you to include extra graphics and images that you would not include in a traditional résumé. Please select the
    12·1 answer
  • Which of the following protocols is used by an email client to retrieve messages from an email server, giving users the option t
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!