Question: Write a program that separates an input array into two arrays. It stores the elements that are greater than a value (entered by the user)

Write a program that separates an input array into two arrays. It stores the elements that are greater than a value (entered by the user) in array larger, and the elements that are smaller or equal to the value in array smaller. The program should include the following function. void separate(int *a, int n, int value, int *larger, int *size, int *smaller); 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 separate function finds the numbers that are greater than value in the array a and store them in array larger. The function finds the numbers that are smaller or equal to value in the array a and store them in array smaller. The fourth parameter size points to a variable in which the function will store the number of larger numbers in the array. The number of elements that are smaller than (or equal to ) value in the array can be calculated by the number of larger numbers and the size of the input array. In the main function, ask the user to enter the length of the array, the array elements, and the value for separating the array, declare the input array with the length, and two output arrays with the same length (the actual length will be determined by the separate function), and call the function. The function will store the actual lengths of the arrays storing the larger numbers. The main function should display the result. Example Input/Output: Enter the length of the array: 8 Enter the elements of the array: 12 0 -4 10 36 7 -8 45 Enter the value for separating the array: 7 Output: Array with elements larger than 7: 12 10 36 45 Array with elements smaller than or equal to 7: 0 -4 7 -8

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To solve this problem you need to write a C program with a function that separates an input array into two arrays based on a given value Heres a stepb... View full answer

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!