Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Define a function that works with c-style arrays of integers. The function should be called subtract and it should pass in 2 arrays and a

Define a function that works with c-style arrays of integers.

The function should be called subtract and it should pass in 2 arrays and a single integer n. The function should change the first n values in the first array to be the difference between the first n values in the first array passed in and the first n values in the second array passed in.

For example, if the arrays passed in to subtract originally stores the values

1 2 3 4 5 6 0 1 2 3 4 5 6 7 8 9 

and the integer passed in is 4 then after the function call the arrays would store the values

1 1 1 1 5 6 0 1 2 3 4 5 6 7 8 9 

In the main function:

  • Read in integer values from cin and store them in the first array until the user enters a -1.
  • Now read in integer values from cin and store them in the second array until the user enters a -1 again.
  • Now read in the single integer (the number of values that will be subtracted).
  • Output the values in both arrays each array on their own line, each value in an array separated by a space.
  • Call the subtract function.
  • Output the values in the arrays again showing that array1 has been changed but array 2 has not.

Do not prompt the user for input. Just read the values in to the array. You may assume there will never be more than 50 integers read in.

You may NOT use the vector class or the array class at all, only the c-style arrays you used in lab 5.

#include

using namespace std;

int main() { return 0; }

ide: zybook C++

Please quick answer. thank you

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

3. What are potential solutions?

Answered: 1 week ago