Question: Lab 8 Compare Two Arrays Objective To practice using arrays to solve a problem. To use function and arrays Problem Define a function that compares

 Lab 8 Compare Two Arrays Objective To practice using arrays to

Lab 8 Compare Two Arrays Objective To practice using arrays to solve a problem. To use function and arrays Problem Define a function that compares two arrays and stores the positions where two array elements are different at into another array. For example, suppose two arrays have the following elements: D C B B A A array1[] A array2[]: A A B A A B A Then the following array, which is generated by the function, holds the positions where the two arrays are different at: diff[]: 2 5 7 Note that this array may not be fully filled up as the example shows! Test your function in a main program. The program should generate the following output: Arrayl and Array2 are different in the following 3 positions: 3, 5, 8 Hint The function should have four parameters: input array1[] and input array2[] and output diff[] and the number of elements in diff[] which is also an output from the function and may be less than the original array size (partially filled). 1/function definition void difference (char array1[1, char array2[], int diff[], int& count) { for (int i=0; i

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!