I just wrote a program with all the source code to find the max, min, range, and standard deviation of a bunch of numbers in an array... Now I have to rewrite the program using prototype commands and functions, I have no idea how to do this. If your interested in helping me and id greatly appreciate if if you would here is the task at hand...
------------------------------------------------------------------------------------
it involves reading a list of numbers, putting them into an array, and computing some statistics about them. But in this assignment, we will break it into smaller pieces using C subfunctions.
Input
Once again, you are to test your program using two input files. Each contains a list of floating-point numbers, one per line. There are between 1 and 40 numbers in each file.
Processing
There will now be a separate function each for 1) reading the input file and building the input array, 2) determining the maximum value, 3) determining the minimum value, 4) computing the range, 5) computing the average value, 6) computing the standard deviation, 7) sorting the array, and 8) printing the array. Therefore, your program will consist of the "driver" (int main) and eight subfunctions called by main, i.e. nine functions altogether. Please note that sorting the array is required in this program.
int main()
The array for the input floating point numbers will be defined in main. It will call the subfunctions in this order: 1) buildArray, 2) printArray, 3) findMax, 4) findMin, 5) calcRange, 6) calcAvg, 7) calcStdDev, 8) sortArray, and, once again, 9) printArray. Print the maximum, minimum, range, number of elements, average, and standard deviation before calling sortArray and printArray. Also, be sure to print an appropriate header for the array in main before calling printArray.
int build(float array[])
The first subfunction will be named build. You will declare the file and do all of the processing of the file in this routine. Once the array is built, close the input file and return the number of entries in the newly built array to main, i.e., you have to count the number of records you read in from the input file and return this integer via the return statement to main. Once again, there may be less than 40 numbers, so you may not fill up all of the array.
void printArray(float array[], int numEnts)
In this subfunction you will print the array six numbers per line as before. The two arguments (or parameters) being passed in are the array and the number of entries in that array. Nothing will be returned.
float findMax(float array[], int numEnts)
In this subfunction you will find the maximum value in the array. The two arguments being passed in are the array and the number of entries. You will return the floating point value determined to be the maximum.
float findMin(float array[], int numEnts)
In this subfunction you will find the minimum value in the array. The two arguments being passed in are the array and the number of entries. You will return the floating point value determined to be the minimum.
float calcRange(float max, float min)
This subfunction is very simple and will calculate the range. It can be done with a single return statement.
float calcAvg(float array[], int numEnts)
This subfunction will calculate the average of the elements in the array and return that value to main.
float calcStdDev(float array[], int numEnts, float avg)
In addition to the array and number of entries, this subfunction will require the average calculated above. Do NOT recalculate it here! Once calculated, return the standard deviation.
void sortArray(float array[], int numEnts)
This subfunction will sort the array in ascending order, i.e., from smallest to largest value.
Output
I need to print the entire array in rows of 6 numbers and print the max, min, range, Dev, and sorted array.
Other Comments
You will need to declare an array of 40 variables of type float.
You will need to open and close the input file as in the previous assignment but this time it's all done in the subfunction buildArray.