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
For the description below, develop an E-R diagram:
xeze [42]

Answer:

See explaination

Explanation:

E-R diagram:

Entity Relationship Diagram, also known as ERD, ER Diagram or ER model, is a type of structural diagram for use in database design. An ERD contains different symbols and connectors that visualize two important information: The major entities within the system scope, and the inter-relationships among these entities.

Please kindly check attachment for for the ERD of the question asked.

4 0
3 years ago
What is the argument in this function =AVERAGE(F3:F26)
monitta
The argument for the function would be answer "D".
5 0
2 years ago
To run a PHP application that has been deployed on your own computer you can enter a URL in the address bar of your browser that
svet-max [94.6K]

Answer:

You can enter a URL that (B) Uses localhost as the domain name

Explanation:

Localhost refers to your computer or the computer that is currently in use.

To run a PHP application that is deployed on your computer, the localhost (which has an IP address of 127.0.0.1) is used.

The IP address is called a "loopback" address because all data sent or received revolve around the local computer.

8 0
3 years ago
Computer-generated color images of the brain that provide information about brain activity and glucose metabolism are produced b
frozen [14]

The answer to this question is the PET scan. Positron Emission Tomography or PET scan is an imaging test that checks and trace for diseases in the body. This also shows how the body organs is functioning / working. The doctor can evaluate the function of the patients body by the 3D color images produced by the PET Scan.  

4 0
3 years ago
Hypertension occurs when blood pressure is too high.
Ivan
True, hypertension is when your blood pressure is to high.
Please mark as brainliest
8 0
3 years ago
Other questions:
  • In procedural programming, where does the flow of control usually route from the main function?
    8·1 answer
  • Please help will mark brainiest
    8·1 answer
  • _______________________ is a short-term program, typically 30 hours long, in which a therapist, social worker, or trained probat
    5·1 answer
  • How do i show all emails from same sender in outlook
    13·2 answers
  • Declare a prototype for a function called isPrime that returns true or false and expects a single parameter named number of type
    14·1 answer
  • Which of the following lists contains the five essential elements of a computer? Group of answer choices: 1. inputs, returns, pr
    11·1 answer
  • Create a program that will read in a Salesperson name, employment status (1=Full-time AND 2=Part-time) and the sales amount.
    5·1 answer
  • Firestick optimizing system storage and applications
    14·1 answer
  • In this paper https://arxiv.org/pdf/2008.10150.pdf, I'm having a hard time understanding how the assignment in the picture is de
    10·2 answers
  • Determine the value of a and b at the end of the following code segment:
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!