Question: I'm having issues with a program I am working on. The question ask to write a program merge.c that reads in two arrays (a1 and
I'm having issues with a program I am working on. The question ask to write a program merge.c that reads in two arrays (a1 and a2) of numbers and creates a new array (a3) of numbers such that the new array contains all the unique numbers of a1 and a2. Assume the input array elements are unique elements. In the main function, ask the user to enter the length of each array, declare and reads in the numbers for each array, and calculate and display the output array. (make sure to remove any duplicate elements that are found in a1 and a2)
Example input/output #1: Enter the length of array 1: 5 Enter the elements of the array: 8 4 1 3 9 Enter the length of array 2: 3 Enter the elements of the array: 5 4 8 Output array: 8 4 1 3 9 5
Example input/output #2: Enter the length of array 1: 4 Enter the elements of the array: 3 4 1 7 Enter the length of array 2: 2 Enter the elements of the array: 6 9 Output array: 3 4 1 7 6 9
For some reason I can't figure out how to merge the two arrays without including any duplicate elements. Please help and point me in the right direction. Thanks!
Here is what my code and output look like:
#include
void merge_array(int arr1[], int num1, int arr2[], int num2);
int main(void){
int first_arr[100]; int second_arr[100]; int num1, num2; int i;
printf("Enter the length of array 1: "); scanf("%d", &num1); printf("Enter the elements of the array: "); for(i = 0; i
void merge_array(int arr1[], int num1, int arr2[], int num2){
int arr3[200]; int i, j, k;// is the count // loop through every element in the array // and remove any duplicate elements that // are found in both arrays. for(i = 0, j = 0, k = 0; (i

Enter the length of array 1: 5 Enter the elements of the array: 84139 Enter the length of the array 2: 3 Enter the elements of the array: 548 Output array: 84139
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
