Question
.(50 points) Write a program arrays.c that compares elements of two integer arrays a and b, and stores the elements in array c that are
.(50 points) Write a program arrays.c that compares elements of two integer arrays a and b, and stores the elements in array c that are either in a or in b, but not in both a and b. For example, array a contains elements {1, 2, 3}, array b contains elements {3, 2, 6, 7}. Array c should contain {1, 6, 7}.
Your program should include the following function: void find_elements(int *a, int n1, int *b, int n2, int *c, int *size);
The function should use pointer arithmetic not subscripting to visit array elements. In other words, eliminate the loop index variables and all use of the [] operator in the function. The find_elements function finds the elements that in either array a or array b, but not both, and stores the result in array c. The function takes an int array parameters a1 and 2 as the first parameter and third parameters and the number of elements of the arrays as the second parameter. The sixth parameter size points to a variable in which the function will store the number of actual elements in array c. In the main function, ask the user to enter the lengths of the arrays, the array elements, declare the input arrays, and the output array with length as the sum of the lengths of the two input arrays (the actual length will be determined by the find_elements function), and call the function. The main function should display the result.
Example Input/Output:
Enter the length of the first array: 5
Enter the elements of the array: 9 8 5 6 4
Enter the length of the second array: 4
Enter the elements of the array: 6 9 7 1
Output: 8 5 4 7 1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started