Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/** * Statistics main driver program * Arrays & Dynamic Memory Lab * CSCE 155E */ #include #include #include stats.h #define MAX_SIZE 100 int main(void)

image text in transcribed

/**

* 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

int *arr = (int *) malloc(sizeof(int) * size);

arr = createRandomArray(size);

//TODO: pass the appropriate variable

readInArray(arr, size);

//TODO: pass the appropriate variables to your functions here

min = getMin(arr,size);

max = getMax(arr,size);

mean = getMean(arr,size);

printArray(arr,size);

printf("Min: %d ", min);

printf("Max: %d ", max);

printf("Mean: %.2f ", mean);

return 0;

}

Activity 4: Dynamic Arrays In this activity you will modify the code in statsMain.c to use a dynamic array instead of a static array. Instructions Alter your static array declaration to be an integer pointer and add code that calls malloc to initialize the appropriate amount of memory. Alter any other code as necessary to remove the "large enough" restriction that we had in the previous activity Run your program again and demonstrate it to a lab instructor 1. 2. 3

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

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

More Books

Students also viewed these Databases questions

Question

Differentiate the function. r(z) = 2-8 - 21/2 r'(z) =

Answered: 1 week ago