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
Stolb23 [73]
2 years ago
14

Given an array temps of double s, containing temperature data, compute the average temperature. Store the average in a variable

called avgTemp . Besides temps and avgTemp , you may use only two other variables -- an int variable k and a double variable named total , which have been declared.Suppose the the temps array had just four elements: 5.4, 8.0, 2.0, and 4.6.Then the value of avgTemp that you would compute would be 5.0, because that is the average of the above four numbers.
Computers and Technology
1 answer:
Ket [755]2 years ago
6 0

Answer:

#include <iostream>

using namespace std;

// average function

void average(double arr[], int n) {

double total = 0;

double avgTemp;

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

{

 // find temperatures total

 total = total + arr[i];

}

// find average

avgTemp = total / n;

cout << "\nAverage Temperature = " << avgTemp << endl;

}

// print temps[] array

void printArray(double arr[], int n) {

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

{

 cout << arr[i] << "   ";

}

}

int main() {

int const k = 5;

double temps[k];

// temperature value

double tempValue;  

// Enter 5 temperatures of your choice

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

{

 cout << "Enter Temperature value " << i+1 << ": ";

 cin >> tempValue;

 temps[i] = tempValue;

}

// Function call to print temps[] array

printArray(temps, k);  

// Function call to print average of given teperatures

average(temps, k);        

return 0;

}

Explanation:

• Inside main(), int constant k is created to set the maximum size of array temps[].

• tempValue of  type double takes value at a given index of our temps[] array.

• the for loop inside main() is used to get tempValue from the user and store those values in our array temps[].

• after that printArray() function is called. to pass an array to a function it requires to perimeters 1) name of the array which is temps in our case. 2) maximum number of the index which is  k.

• note the syntax of void average(double arr[], int n). Since we are passing an array to the function so its formal parameters would be arr[] and an int n which specifies the maximum size of our array temps[].

You might be interested in
A new object of type list is created for each recursive invocation of f.A. TrueB. False
sammy [17]

Answer:

True but double check!

7 0
2 years ago
Select the correct answer.
sveticcg [70]

Answer:

D

Explanation:

5 0
3 years ago
Read 2 more answers
What is one way polymorphism is implemented?
podryga [215]

Answer:

repurposing an operation

Explanation:

Got it right

8 0
3 years ago
How does the results window display your performance in Rapid Typing application ?
LiRa [457]

Answer:

RapidTyping is a convenient and easy-to-use keyboard trainer that will help you improve your typing speed and reduce typos. With its lessons organized for various student level, RapidTyping will teach you touch typing or enhance existing skills.

Typing tutor can be used both in the classroom under the guidance of teacher, as well as for self-study. Available export the training statistics in the different formats and creating your own training courses.

8 0
3 years ago
1. software that helps run the computer hardware
leva [86]
1. System software 2. Mother board 3. Program 4.CPU 5. Laptop




7 0
3 years ago
Other questions:
  • Mobile devices typically come pre installed with standard apps like web browsers , media players, and mapping programs true or f
    9·1 answer
  • Java languageThe cost to ship a package is a flat fee of 75 cents plus 25 cents per pound.1. Declare a constant named CENTS_PER_
    5·2 answers
  • An excel user should use a relative cell reference when it is important to ____. preserve the relationship to the formula locati
    7·1 answer
  • You want to implement a mechanism that automates ip configuration, including ip address, subnet mask, default gateway, and dns i
    14·1 answer
  • Which design element involves the act of lining up objects vertically or horizontally to give a sense of order?
    15·1 answer
  • One advantage of using a security management firm for security monitoring is that it has a high level of expertise.
    15·2 answers
  • Which Additional Authorization List item can replace the hook at the end of the winch cable for fastening the cable to some load
    12·1 answer
  • A ___ is an online collaborative event that may include such features as chat, slideshows, and PowerPoint presentations.
    8·1 answer
  • Define power supply and types of power supply<br>​
    11·1 answer
  • When typing lists in a document, you must use single-spacing between each item in the list.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!