Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a directory called lab8. Within this directory, complete the program, shown below, named lab8.c. You can download this file from Blackboard. Write the five

image text in transcribed

Create a directory called lab8. Within this directory, complete the program, shown below, named lab8.c. You can download this file from Blackboard. Write the five functions shown in red. #include #include int **allocateMatrix(int, int) ; void initMatrix(int **, int, int) int findRange (int**, int, int) double findAverage (int *, int, int) void printCorners (int **, int, int) ; int main(int argc, char *argvl) int **data; int row = atoi (argv [1]) ; int col = atoi (argv [2]); data allocateMatrix (row, col) initMatrix (data, row, col) printf ("The range of values is %d ", ) row, findRange (data, col) row, findAverage (data, col) ); printf ("The average of all values is %1f ", printcorners (data, row, col) return 0 A sample execution of this program is shown below ./a.out 2 2 The range of values in the array is 532 The average of all array values is 740.250000 383 886 777 915 A brief description of each of the five functions you have to write is given below allocateMatrix Takes the number of rows and columns. Allocates space for the matrix, returning a pointer to that location in memory. Recall that to allocate space for the matrix, you: Declare anint ** variable (which you will return to the calling program) Allocate space to point to all the "rows" in the matrix ("row" pointers) o o o For each row in the matrix, allocate space for all integers on that row ("column" integers) initMatrix Takes a pointer to the array and the number of rows and columns. Initialize all values in the matrix to a random value in range of 0-999. Make sure to seed your random number generator using srand (0) ; at the start of your function. findRange Takes a pointer to the array and the number of rows and columns. Calculates and returns the range of the elements in the matrix. Recall the range of an matrix is the largest value minus the smallest value in the matrix. findAverage Takes a pointer to the array and the number of rows and columns. Calculates and returns the average value (a double) of all elements in the matrix printcorners Takes a pointer to the array and the number of rows and columns. Prints the four values at the corners of the matrix

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

Step: 3

blur-text-image

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

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions