Here are the assignment instructions. I have the c program attached.
Write a program and functions that will get 2 sets of random numbers from a random number
generator, average the 2 sets, and calculate the difference in the two averages. More specifically,
the program should do the following:
- Include these files: stdio.h, stdlib.h, and time.h
- Main function
a. Define manifest constant NSIZE1 and NSIZE2 for the number of values in data
sets 1 and 2, respectively. Set their values to 4 and 8, respectively.
b. Declare arrays to hold the sets of random numbers. The arrays should be of type
double.
c. Include the statement:
srand((unsigned int) time(0));
before calling rand(). The call to srand() will initialize the random number
generator; it should only be called one time. srand() is defined in stdlib.h and
time() is defined in time.h.
d. Fill the arrays with data by calling FillArray() which is a function that you write.
e. Compute the average for each set of values by calling a dAvg() function which is
another function that you create. This function should return the average as a
double value and should accept a 1-dimensional array of values to be averaged.
f. Determine the largest value in each set of data by calling a dMax() function that
you write. dMax() should accepted a 1-dimensional array and return the
maximum value as a double value.
g. In your main function, print out the results in the following format:
i. The number of data sets and the number of items in a data set.
ii. For the first set of data, print its average, a colon, and then the values of its
items on one line.
iii. On the next line, print the second set’s average, a colon, and then the
values of its items.
iv. On the next line print the differences (set 1 – set 2) in the 2 sets’ average
and maximum values. Be sure to clearly label your results. - void FillArray(double vs[], int nVals); // Prototype
a. Uses the following expression to fill the array with random data.
rand()*10.0/RAND_MAX
b. rand() is defined in stdlib.h and returns an integer value in the range of 0 to
RAND_MAX.
c. Does not return a value.( - double dAvg(double vs[], int nVals); // Prototype
a. Returns a double value containing the average value for an array of doubles that is
passed to it. - double dMax(double vs[], int nVals); // Prototype
a. Returns a double value containing the maximum value in the array that is passed
to it.
OUTPUT
PLACEHOLDER NAME
Analysis of Data. . .
Number of datasets: 2
Number of items in set 1: 4
Number of items in set 2: 8
(No return value, program will not close. Maybe has to do with one of the loops I have?)