Question: NEEDS TO BE WRITTEN IN C! Write a program and functions that will do the following: 1. Include these files: stdio.h, stdlib.h, and time.h 2.
NEEDS TO BE WRITTEN IN C!
Write a program and functions that will do the following:
1.
Include these files: stdio.h, stdlib.h, and time.h
2.
Main function
a.
Declare a 3x5
array of double values (3 rows with 5 number per row).
b.
Include the statement:
srand((unsigned int) time(0));
before calling dRand(). The call to srand() will initialize the random number
generator.
srand() is defined in stdlib.h and time() is defined in
time.h.
c.
Use for loops to initialize the 3x5 array by calling dRand() which is a function
that you write.
d.
Compute the average for each row of 5 values by calling a dAvg() 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 average. Your main function should
call it 3 times
once for each row.
e.
Calculate the average of all 15 values.
f.
Determine the largest value of the 15 values by calling a dMax() function that you
write.
dMax
()
should accepted a 2
-
dimensional array and return the maximum
value as a double value.
g.
Print out the results in the following format:
i.
3 rows of initial values with the average value for the row shown at the
right end of the row.
ii.
The average value o
f all 15 values
appropriately label the results.
iii.
The maximum value of the 15 values
appropriately label the results.
3.
double
dRand(
void
)
a.
Returns the result of this calculation:
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.
4.
dAvg()
a.
Returns a double value containing the average value for an array of doubles that is
passed to it.
5.
dMax()
a.
Returns a double value containing the maximum value in the 2 dimensional array
that is passed to it

Write a program and functions that will do the following: 1. Include these files: stdio.h, stdlib.h, and time.h 2. Main function a. Declare a 3x5 array of double values (3 rows with 5 number per row). b. Include the statement: srand (unsigned int) time (0)); before calling dRand0. The call to srand0 will initialize the random number generator. sran is defined in stdlib.h and time0 is defined in time.h. c. Use for loops to initialize the 3x5 amay by calling dRand0 which is a function that you write d. Compute the average for each row of 5 values by calling a dAvg0 function that you create. This function should retum the average as a double value and should accept a 1-dimensional array of values to be average. Your main function should call it 3 times once for each row. e. Calculate the average of all 15 values. f Determine the largest value of the 15 values by calling a dMax0 function that you write. dMax0 should accepted a 2-dimensional amay and retum the maximum value as a double value. g, Print out the results in the following format: i. 3 rows of initial with the average value for the row shown at the right end of the row. ii. The average value of all 15 values-appropriately label the results. iii. The maximum value of the 15 values-appropriately label the results. 3 double dRand (void) a. Retums the result of this calculation: rand 10.0 RAND MAX b. rand 0 is defined in stdlib.h and returns an integer value in the range of 0 to RAND MAX. 4. dAvg0 a. Returns a double value containing the average value for an amay of doubles that is passed to it. 5. dMax0 a. Returns a double value containing the maximum value in the 2 dimensional amay that is passed to it
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
