Reference no: EM132196156
Write a C program with the following functions (plus any helper functions youdecide to write):
show: Write a function named show that has 2 args: the first arg is an array of
doubles and the second arg is an unsigned that is the number of elements in thearray. show will not change the array. show may assume without checking that thearray has at least one element. show has no return value. show's job is to output the # of elements in the array, enclosed in []the values of the elements, separated by commas (no comma before the first
element or after the last element).
An example of the output that show might produce (if the array had 5 elements) is [5] 1.1, 2.2, 3.3, 4.4, 5.5(I'm not fussy about formatting niceties like how many digits are displayed after thedecimal point, as long as the values are correct.)
squareAll: Write a function named squareAll that has 2 args: the first arg is an array of doubles and the second arg is an unsigned that is the number of elements inthe array. squareAll may assume without checking that the array has at least oneelement. squareAll has 2 jobs: first, it will square each element in the arraysecond, it will return the sum of those squares. (squareAll doesn't output that
sum, it just returns it.)
For example, if the array held {1.1, 2.0, 3.0} on entry (so the second arg would be 3),then squareAll would change the array to {1.21, 4.0, 9.0} and return 14.21. (Ofcourse, your function will work for arrays of any size, not just size 3.
minAve: Write a function named minAve that has 4 args:
The first arg is a pointer to a double variable in the caller. This double variable isunpredictable garbage when minAve starts. minAve will change this double tothe minimum value. For example, if the third arg held {2.0, 1.0, 9.0} (so thefourth arg would be 3), then minAve would set this double to 1.0 .The second arg is a pointer to another double variable in the caller. This doublevariable is also unpredictable garbage when minAve starts. minAve willchange this double to the average value. For example, if the third arg held
{2.0, 1.0, 9.0}, then minAve would set this double to 4.0 .The third arg is an array of doubles. minAve will not change this array.The fourth arg is an unsigned that is the number of elements in the array. minAvemay assume without checking that the array has at least one element.
main: Your main function should
create an array of doublessomehow get values into the arraycall show to display the array contentspass the array to squareAll to square all the elements of the array.call show again to display the array contents after squaringcall minAve to get the minimum and average values in the arrayOutput the minimum and average values with explanatory textFor example, of your array held {10.0, 1.0, 4.0}, then your main should outputsomething like[3] 10.0, 1.0, 4.0[3] 100.0, 1.0, 16.0min is 1.0, ave is 39.0