Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Semantics In Databases Second International Workshop Dagstuhl Castle Germany January 2001 Revised Papers Lncs 2582

Authors: Leopoldo Bertossi ,Gyula O.H. Katona ,Klaus-Dieter Schewe ,Bernhard Thalheim

2003rd Edition

3540009574, 978-3540009573

More Books

Students also viewed these Databases questions