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]
3 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]3 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
There are two kinds of emotions: positive and negative. True False
fgiga [73]

Answer:

False

Explanation:

There are many emotions the human brain can experience

6 0
2 years ago
Read 2 more answers
To change lowercase letters to uppercase letters in a smaller font size, which of the following should be done?
sergeinik [125]

Explanation:

Format the text in Small caps. Manually replace the lowercase letters with uppercase letters.

7 0
3 years ago
__________ is the electronic transmission of signals for communications, which enables organizations to carry out their processe
Serjik [45]

Telecommunications is the electronic transmission of signals for communications, which enables organizations to carry out their processes and tasks through effective computer networks

4 0
3 years ago
When inserting a fly in animation what is the first step in the process?
weqwewe [10]

Answer:

you select the element you wish to animate

6 0
3 years ago
The collection of computer instructions and other files that constitute a piece of software is
lutik1710 [3]
The answer would be
A. Codebase

8 0
3 years ago
Read 2 more answers
Other questions:
  • Why dose this keep popping up will give brainlest for first person answer
    12·1 answer
  • 11. You should type _
    6·2 answers
  • ________ computers are specially designed computer chips that reside inside other devices, such as a car. Select one: A. Tablet
    11·2 answers
  • . Hackers generally disguise their IP address. True False
    9·1 answer
  • Vitamins and minerals dissolve easily in water.True or false?
    5·1 answer
  • Which of the following is the Boolean logical operator for OR in C#?
    12·2 answers
  • A system is composed of four parts, J, K, L, and M. All four must function for the system to function. The four component reliab
    6·1 answer
  • Suppose the cache access time is 10ns, main memory access time is 200ns, and the cache hit rate is 90%. Assuming parallel (overl
    10·1 answer
  • Budgeting for a Computer
    6·1 answer
  • windows switches to secure desktop mode when the uac prompt appears. what is the objective of secure desktop mode?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!