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
Murljashka [212]
3 years ago
8

1-(50 points) The function sum_n_avgcomputes the sum and the average of three input arguments and relays its results through two

output parameters.a)Write a prototype for a function sum_n_avgthat accepts three double-type inputparameters and returns two output parameters through reference.b)Write the function definition for function sum_n_avg. The function definition is where the actual computations are performed.c)Write a function call in main ()forsum_n_avg. The function call can look like below free
Computers and Technology
1 answer:
MAXImum [283]3 years ago
5 0

Answer:

The program in C++ is as follows:

#include <iostream>

using namespace std;

double *sum_n_avg(double n1, double n2, double n3);

int main () {

   double n1, n2, n3;

   cout<<"Enter 3 inputs: ";

   cin>>n1>>n2>>n3;

   double *p;

   p = sum_n_avg(n1,n2,n3);

   cout<<"Sum: "<<*(p + 0) << endl;

   cout<<"Average: "<<*(p + 1) << endl;

  return 0;

}

double *sum_n_avg(double n1, double n2, double n3) {

  static double arr[2];

  arr[0] = n1 + n2 + n3;

  arr[1] = arr[0]/3;

  return arr;

}

Explanation:

This defines the function prototype

double *sum_n_avg(double n1, double n2, double n3);

The main begins here

int main () {

This declares variables for input

   double n1, n2, n3;

This prompts the user for 3 inputs

   cout<<"Enter 3 inputs: ";

This gets user inputs

   cin>>n1>>n2>>n3;

This declares a pointer to get the returned values from the function

   double *p;

This passes n1, n2 and n3 to the function and gets the sum and average, in return.

   p = sum_n_avg(n1,n2,n3);

Print sum and average

<em>    cout<<"Sum: "<<*(p + 0) << endl;</em>

<em>    cout<<"Average: "<<*(p + 1) << endl;</em>

  return 0;

}

The function begins here

double *sum_n_avg(double n1, double n2, double n3) {

Declare a static array

  static double arr[2];

Calculate sum

  arr[0] = n1 + n2 + n3;

Calculate average

  arr[1] = arr[0]/3;

Return the array to main

  return arr;

}

You might be interested in
Explain the steps you take when conducting research online to ensure it the source is providing reliable information.
Gala2k [10]

Answer:

Author

Date and

Source

Explanation:

Author – Information on the internet with a listed author is one indication of a credible site. ...

Date – The date of any research information is important, including information found on the Internet. ...

Sources – Credible websites, like books and scholarly articles, should cite the source of the information presented.

5 0
3 years ago
Amina question and any other )
Anon25 [30]

Answer:

h b

Explanation:

8 0
3 years ago
True or False: From an antiterrorism perspective, espionage and security negligence are considered insider threats.
Oksanka [162]
MAYBE is false...............
6 0
3 years ago
Read 2 more answers
To reload a picture taken with a digital camera means to copy the digital picture from the camera to your computer.
goldenfox [79]
The answer would be false.
7 0
3 years ago
Read 2 more answers
BUURTAIS
Alisiya [41]

Answer:

what I'm confused ???????

Explanation:

?

4 0
3 years ago
Other questions:
  • What is output with the statement System.out.println(x+y); if x and y are int values where x=10 and y=5? Group of answer choices
    10·1 answer
  • True or false. Every word has only one correct spelling and pronunciation.
    6·1 answer
  • What is the problem we can't build shelter on mars ?
    6·1 answer
  • Given the variable ip, already declared as a pointer to an integer, write the code to dynamically allocate memory for a single i
    15·1 answer
  • Write two statements to read in values for my_city followed by my_state. Do not provide a prompt. Assign log_entry with current_
    13·1 answer
  • 9. Which of the following commands is executed with the shortcut 'Ctrl+Z'?
    11·1 answer
  • Which 2 processes are operational processes
    10·1 answer
  • What is one example of an emerging class of software
    12·1 answer
  • Pls help I don’t know the answers
    15·1 answer
  • How to work a computer cause i don't know how to
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!