Question: This is the code: stats.c: #include #include #include stats.h //TODO: fix the error in this function void readInArray(int *arr, int size) { int i; printf(Enter

 This is the code: stats.c: #include #include #include "stats.h" //TODO: fix

This is the code:

stats.c:

#include #include

#include "stats.h"

//TODO: fix the error in this function void readInArray(int *arr, int size) { int i; printf("Enter your list of numbers: "); for (i = 0; i

int * generateRandomArray(int size) { int * randomArr = malloc(sizeof(int) * size); for(int i=0; i

void printArray(const int *arr, int size) { printf("["); for(int i=0; i

double getMean( , ) {

}

int getMin( , ) { }

int getMax( , ) {

}

stats.h :

/** * This function prompts and reads in a collection of numbers * from the standard input and populates the given array. The * provided array must be properly initialized for this function * to work. */ void readInArray(int *arr, int size);

/** * Generates a random array of integers of the given * size. This function assumes that the random number * generator has already been seeded. */ int * generateRandomArray(int size);

/** * Prints the given array to the standard output */ void printArray(const int *arr, int size);

/* * TODO: * 1. Write prototypes for each of these functions * 2. Write documentation for each of these functions * 3. Implement the functions in stats.c */ double getMean( , ); int getMin( , ); int getMax( , );

3.1 Static Arrays Navigate back to the statistics directory. Several files have been provided for you. The stats.c and stats.h file define several utility functions to manipulate arrays and to compute statistics on those arrays. The statsMain.c file contains a main driver program. Recall that you will compile these files using: gcc -c stats. gcc -o runstats stats. o statsMalnc In this activity, you will implement and use several functions that use arrays as parame- ters. When passed as a parameter to a function, the function also needs to be told how large the array is; typically an integer size variable is passed with any array parameter You will also declare and populate a static array to test your functions. Instructions 1. A function, readInArray has been provided for you that takes an array and its size and prompts the user to enter values to populate the array. However, there is an error in the function: examine the scanf call and determine what is wrong and fix it before proceeding 2. Using the other functions as a reference, implement the getMin, getMax, and getMean functions. You will need to provide the correct function signature in both the header file and source file 3. In the statsMain.c declare a static array that is "large enough" as indicated by the other clues in the code. Use your declared static array as an argument to readInArray and the other function calls. 4. Run your program and demonstrate it to a lab instructor

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!