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
zmey [24]
3 years ago
9

Write a program that will input temperatures for consecutive days. The program will store these values into an array and call a

function that will return the average of the temperatures. It will also call a function that will return the highest temperature and a function that will return the lowest temperature. The user will input the number of temperatures to be read. There will be no more than 50 temperatures. Use typedef to declare the array type. The average should be displayed to two decimal places
Computers and Technology
1 answer:
Anna [14]3 years ago
5 0

Answer:

#include <iostream>  

using namespace std;

typedef double* temperatures;

double avg(array t, int length);

double min(array t, int length);

double max(array t, int length);

int main()

{

   cout << "Please input the number of temperatures to be read." << endl;

   int num;

   cin >> num;

   temperatures = new double[num];

   for(int i = 0; i < num; i++)

   {

       cout << "Input temperature " << (i+1) << ":" << endl;

       cin >> temperatures[i];

   }

   cout << "The average temperature is " << avg(temperatures, num) << endl;

   cout << "The highest temperature is " << max(temperatures, num) << endl;

   cout << "The lowest temperature is " << min(temperatures, num) << endl;

}

double avg(array t, int length)

{

   double sum = 0.0;

   for(int i = 0; i < length; i++)

       sum += t[i];

   return sum/length;

}

double min(array t, int length)

{

   if(length == 0)

       return 0;

    double min = t[0];

   for(int i = 1; i < length; i++)

       if(t[i] < min)

           min = t[i];

   return min;

}

double max(array t, int length)

{

   if(length == 0)

       return 0;

      double max = t[0];

   for(int i = 1; i < length; i++)

       if(t[i] > min)

           max = t[i];

   return max;

}

Explanation:

The C++ program get the array of temperatures not more than 50 items and displays the mean, minimum and maximum values of the temperature array.

You might be interested in
Computer applications
posledela

Answer:

please tell the question clearly

8 0
3 years ago
Explain why this product was created?
velikii [3]

Explanation:

Product was created becaus the first and most important reason for any new development is to provide new value to the customer. Without this, there is no reason for them to trade their money for the new device. However, if the product or service offers overwhelming value, then customers will flock to it.

7 0
3 years ago
How many basic elements of QBASIC are there
Masteriza [31]
<h2>6</h2>

The elements used in Qbasic:

  • Character set.
  • Variables.
  • Constants.
  • Operator and Operands.
  • Expression.
  • Statements.
6 0
3 years ago
For which is a chart legend used?
ruslelena [56]
All of the time is a type of chart legend using....
7 0
3 years ago
#include
meriva

Answer:

wait what

Explanation:

6 0
2 years ago
Read 2 more answers
Other questions:
  • I can't see the answer
    13·2 answers
  • How can you get access to Help? Click all that apply.
    5·2 answers
  • How does is make you feel when you're kind to others? What are some opportunities in your life to be more kind to your friends a
    9·1 answer
  • What are the three primary separation of concerns on the client-side of a dynamic web application? (Check all that apply)
    13·1 answer
  • Tawni made some changes to her file and wants to save the changes in a document with a different title. How can she do this?
    14·2 answers
  • What is the useful chart used for comparing values over categories?​
    8·1 answer
  • Cash cows are always in
    7·1 answer
  • Write a program that prompts the user to enter a number then counts the number of odd numbers and even numbers the user enter. T
    15·1 answer
  • Get someone get her for me if need snap kell.c11
    10·1 answer
  • In the previous project, you are storing the first name of the gamer. Write a phrase to the game right before the first word wit
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!