statsc include include include statsh This function prompt
///stats.c//
#include
#include
#include \"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.
*
* //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 < size; i++) {
scanf(\"%d\", arr[i]);
}
return;
}
/**
* Creates an array of the given size and populates it
* with random integers between 0 and 99. This function
* assumes that the standard library\'s random number
* generator has already been seeded.
*/
int * createRandomArray(int size) {
int i;
int *arr = NULL;
arr = (int *) malloc(sizeof(int) * size);
for(i=0; i arr[i] = rand() % 100;
}
return arr;
}
/**
* Prints the given array to the standard output in a
* nicely formatted, readable manner.
*/
void printArray(const int *arr, int size) {
int i;
printf(\"[\");
for(i=0; i printf(\"%d, \", arr[i]);
}
if(size > 0) {
printf(\"%d\", arr[size-1]);
}
printf(\"]\ \");
}
/**
* TODO: this function computes the mean (average) of
* the numbers contained in the given array
*/
double getMean( , ) {
}
/**
* TODO: this function finds and returns the minimum element
* of the numbers contained in the given array
*/
int getMin( , ) {
___________
//stats.h//
void readInArray(int *arr, int size);
int * createRandomArray(int size);
void printArray(const int *arr, int size);
//TODO: provide the prototypes for each of these functions
double getMean( , );
int getMin( , );
int getMax( , );
______________
//statsMain.c//
/**
* Statistics main driver program
* Arrays & Dynamic Memory Lab
* CSCE 155E
*/
#include
#include
#include \"stats.h\"
#define MAX_SIZE 100
int main(void) {
//pay no attention to the man behind the curtain
srand(time(NULL));
int min, max, size;
double mean;
printf(\"Enter the amount of numbers you\'d like to find the stats for: \");
scanf(\"%d\", &size);
if(size > MAX_SIZE) {
printf(\"ERROR: program does not support that many integers!\");
exit(1);
}
//TODO: declare a static array \"large enough\" to hold as many integers as we\'ll need
//TODO (Activity 3): change your delcaration and initialization to use
// a dynamic array and malloc instead
//TODO: pass the appropriate variable
readInArray(, size);
//TODO: pass the appropriate variables to your functions here
min = getMin( , );
max = getMax( , );
mean = getMean( , );
printArray( , );
printf(\"Min: %d\ \", min);
printf(\"Max: %d\ \", max);
printf(\"Mean: %.2f\ \", mean);
return 0;
}
Solution
void readInArray(int* arr, int size)
{
int i;
printf(\"Enter your list of numbers: \");
for (i = 0; i < size; i++) {
scanf(\"%d\", arr[i]);
}
return;
}
void readInArray(int* arr, int size) ;
now check code once


