Question: C GCC and Arrays Problem 4 For this problem, we will gain more experience using arrays and functions, and we will also consider the similarities

C C GCC and Arrays Problem 4 For this problem, we will gain

GCC and Arrays Problem 4 For this problem, we will gain more experience using arrays and functions, and we will also consider the similarities and differences between floats and doubles. Write a method called average_float() that accepts as a parameter an array of floats and then returns the average value in the array as a float. You may assume that the array has at least one element. Write a new program called average.c that tests this routine. In the main routine, initialize an array of floats called f_array with the values listed below, compute the average using your average() method, output the array, and then output the result (e.g. "average value is "). Array Values: 9.10938356x19", -1, 2./3., 1.618033988749895, 2.71828182845904523536, 339/108, , 1.23x10, 299792458, 5.68319x1026 Next, copy the average_float() routine and paste it below the original, calling it average_double(). Modify it so that it returns the average of an array of doubles instead of floats, and that the return value is also a double. Add a new array to your main() method called d_array, initialized to the same values as before, compute the average, and output the array and result as before. What differences do you observe between the two outputs? Compare and contrast the results, and explain why the differences happen

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!