Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 image text in transcribed
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

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_2

Step: 3

blur-text-image_3

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

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

What does stickiest refer to in regard to social media

Answered: 1 week ago