Reference no: EM132196142
Write a C program with the following functions:
die
show: a void function with 2 args: an array of ints, which show doesn't change, and the number of elements in the array.
show's job is to output the array values,separated by commas, without a comma before the first element or after the lastelement.
e.g. 3, 5, -17, 0, 8
show may assume without checking that the array has at least one element.
positive: this function returns a pointer to a dynamically allocated array.
It has 3 args: a pointer to an unsigned (the unsigned is garbage on entry)
an array of ints, which I'll call a. positive doesn't change a, and positive may
assume without checking that a contains at least one positive number
the number of elements in a positive will:
dynamically allocate (DA) an array of ints that will hold all the positive ints in a.
only allocate as many bytes as necessary for the positive elements.
copy the positive ints from a to the DA array
set the unsigned that the first arg points to to the number of elements in the DA array
main will
create an array of ints, and get values into it (you decide how).
pass the array to positive to get a DA array of positive numbers
call show to output the positive numbers
deallocate the DA array.