Question: Write a program that compares two arrays element by element, counting the number of elements that are greater than the other for each array. Assume
Write a program that compares two arrays element by element, counting the number of elements that are greater than the other for each array. Assume you have arrays a1 and a2 each having N elements. If a10 > a20, then a10 gets a point, if a10 < a20, then a20 gets a point, if the two are = neither get a point. Continue this process for all N elements. Write the compareElements function.
Prototype:
int* compareElements(int sz, int* arr1, int* arr2);
sz: represents the size of the arrays
arr1 and arr2: the arrays that will be compared element by element.
int* : the return type. You will return an array with 2 elements that will hold the output count.
Sample input:
6 7 9 2 6 0 10 6 10 19 1 0 8
The ouput would be: 3 2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
