Question: C++ language Suppore you have a main() function with two local arrays, all the same size and type (say double). The first two are already

C++ language

Suppore you have a main() function with two local arrays, all the same size and type (say double). The first two are already initialized to values. Write a function called addArrays() that accepts the address of the two arrays as arguments; adds the contents of the two arrays together, element by element; and returns the result as a pointer. The function addArrays() returns a pointer to a double. The main() program declares a pointer which is set equal to addArrays using a statements like

int *numbers = nullptr;

and later on...

numbers = addArrays(arr1, arr2, ARRSIZE);

You must use pointer notation throughout the program. The only time when you may use brackets is when defining arrays or dynamically allocating memory. Otherwise, the expectation is that you use pointer notation throughout the design of your program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!