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
Neporo4naja [7]
3 years ago
11

Write the definition of a function named averager that receives a double parameter and returns-- as a double -- the average valu

e that it has been passed so far. So, if you make these calls to average, averager(5.0), averager(15.0), averager(4,3), the values returned will be (respectively): 5.0, 10.0, 8.1.
Computers and Technology
1 answer:
vladimir1956 [14]3 years ago
7 0

Answer:

double averager (double &newNumber)

{

static double sum = 0.0;

static int counter = 0;

counter++;

sum += newNumber;

return sum / counter;

}

Explanation:

This exercise is for you to understand how to use variables in functions that have scope outside of the function. The static keyword before a initialising a variable whether int or double or float or string, place the variable on the STATIC MEMORY. This means that when the function ends, those static variables are still usable and can be manipulated with the same stored values.  So when the function sees the

static double sum = 0.0;

for the second time it IGNORES it and continues with the previously stored value.

You might be interested in
Select the correct answer.
vredina [299]
The answer is B I did the test
4 0
3 years ago
What is the importance of using the proper markup language?
Klio2033 [76]

the answer is D. without the right tags the content wont be accurately indexed

3 0
4 years ago
Read 2 more answers
In a file-oriented information system, a transaction file ____.
Dima020 [189]
Is it a multiple choice answer?
8 0
3 years ago
Given a int variable named callsReceived and another int variable named operatorsOnCall write the necessary code to read values
erik [133]

Answer:

The code to this question can be given as:

Code:

int callsReceived,operatorsOnCall;    //define variable  as integer

Scanner ob= new Scanner(System.in);    

//create object of scanner class for user input

System.out.println("Insert the value of callsReceived");  //print message.

callsReceived = ob.nextInt();    //input value.

System.out.println("Insert the value of operatorsOnCall"); //print message.  

operatorsOnCall = ob.nextInt();    //input value.

if (operatorsOnCall == 0)  //check number  

{

System.out.println("INVALID");   //print message.

}

else

{

System.out.println(callsReceived/operatorsOnCall);   //print value.

}

Explanation:

In the above code firstly we define 2 integer variable that name is already given in the question. Then we create the scanner class object for taking user input. Then we print the message for input first and second value from the user. then we use conditional statement. If the second variable that is  operatorsOnCall is equal to 0. So It print INVALID. else it divide the value and print it.

3 0
3 years ago
A function prototype can always be omitted when: A function is defined before it is first invoked. A function does not return a
krok68 [10]

Answer:

A function is defined before it is first invoked.

Explanation:

A function prototype is a term in computer programming that is used as the declaration of a function that specifies function's name, parameters and return type. However, unlike function itself, which specifies what it does, a function prototype specifies function's interface only and not what it does.

Hence, A function prototype can always be omitted when: a function is defined before it is first invoked.

4 0
3 years ago
Other questions:
  • Express the worst case run time of these pseudo-code functions as summations. You do not need to simplify the summations. a) fun
    8·1 answer
  • Using a loop, write a program that reads in exactly five integers and outputs the sum.
    11·1 answer
  • What kind of networking is only for the use of people within the company
    8·2 answers
  • Select the components of a search engine.
    13·2 answers
  • What is considered to be the core of the Unix operating system ?
    14·1 answer
  • How long are most personal vision statements?
    13·1 answer
  • Which of the following statements comparing debit cards to credit cards is TRUE?
    13·2 answers
  • 3. In 1989, the first handheld console was released by _____ and it was called ________.
    11·1 answer
  • Any movie/show suggestions??
    7·2 answers
  • Give an example of how loops are used in programming Kturtle​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!