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
Ok so another weird question! So if you know what google drive is and how to upload a video why does it keep adding hours! it ke
lesya [120]

Answer:Your video may be too long and you may not have that much storage left.

Explanation:

5 0
4 years ago
State 10 differences between video conferencing and teleconferencing​
mr_godi [17]
Answer:
Teleconferencing is voice-only or audio and video communication, while video conferencing supports the conference by providing both video and voice, so you can fully see the person when you are listening to the communicator,

Teleconferencing is capable of transmitting the data during the conference, either using traditional PBX systems or VoIP, while video conferencing offers VoIP services. The formal requires less bandwidth, while the latter is highly dependent on network bandwidth.


6 0
2 years ago
Does a wizard function allow the user to enter or modify data in the records? select yes or no
mojhsa [17]
Yes wizard function allows you to modify records

4 0
3 years ago
What is a back door?
V125BC [204]

Answer:

A backdoor is a typically covert method of bypassing normal authentication or encryption in a computer, product, embedded device, or its embodiment. Backdoors are most often used for securing remote access to a computer, or obtaining access to plaintext in cryptographic systems.

Explanation:

3 0
3 years ago
Read 2 more answers
Question 7 * What is the default powerpoint standard layout A Blank B Title slide C Title only D. Comparison ​
lesantik [10]

Answer:

B. <u>Title</u><u> </u><u>slide</u><u> </u>layout is the default PowerPoint standard layout.

3 0
2 years ago
Other questions:
  • Pointers with classes a) A user-defined class named Timer has a constructor that takes two integer parameters to initialize hour
    14·1 answer
  • How much power is consumed by a 1.4A motor connected to a 12V battery?​
    11·1 answer
  • To retrieve an outlook express e-mail header right-click the message, and then click ____ to open a dialog box showing general i
    7·1 answer
  • Irena sends unwanted e-mails to another girl in her class, but she is reported to the principal. Irena stops sending the e-mails
    12·2 answers
  • QUESTION 4 PRACTICAL EXERSIZE
    7·1 answer
  • What breakthrough in sound recording facilitated stereophonic recording? Ο Α. overdubbing O B. multitrack recording O C. digital
    10·1 answer
  • What kind of data are spreadsheets typically used with?
    6·1 answer
  • Assume the following:
    10·1 answer
  • What is the name given to software that decodes information from a digital file so that a media player can display the file? har
    11·1 answer
  • State three reasons why users attach speakers to their computer​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!