Question: Write a C program positive.c that includes the following function. void extract(int *a,int n, int *positive, int *size); The function should use pointer arithmetic not

Write a C program positive.c that includes the following function.

void extract(int *a,int n, int *positive, 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 extract function finds the positive numbers in the array a and store them in array positive. The function takes an int array parameter as the first parameter and its number of elements as the second parameter. The third parameter is the array of positive numbers, and the fourth parameter size points to a variable in which the function will store the number of positive numbers in the array.

In the main function, ask the user to enter the length of the array, declare the input array with the length, and output array with the same length (the actual length will be determined by the extract function), and call the function. The function will store the actual length of the array storing the positive 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 0 36 7 -89 45

Output: 4 36 7 45

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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!