Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

.(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

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: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions