Question: Write a C program that accepts two integer numbers N and M, dynamically allocate a two dimensional array of size N x M, and fill

Write a C program that accepts two integer numbers N and M, dynamically allocate a two dimensional array of size N x M, and fill it (the 2D array) row by row with random integers between 1 and 10.

You should define a function that takes a 2D array and an integer that represents a row in the received 2D array, this function should return the sum of all elements in that rowi.

Of course, you should call this function N times to find the sum of all rows. The returned results (sum of all elements in one row of the 2D) should be stored in a corresponding cell of a result 1D array that is also dynamically allocated of size N.

Another function should be written to find the maximum value in a 1D array, the array of results can be used to find the max of all sums of rows.

Notes:

1. Make sure to properly allocate and deallocate your arrays/memory without any waste of resources. Fixed size arrays will not be accepted, your array must be filled with random integers in the range [1-10]

2. You should pass the size of the used array using the argc and argv of the main() function, E.g. $ ./a.out 10 5 should dynamically allocate an array A10x5. Any use scanf() will not be accepted

4. You should split your program over multiple C source files, different functions can be in different source files, compile each file with gcc c and then linking them using the o option. (at least three source files are required). A Makefile should be written to allow you to build, rebuild, and clean the project as it was described in class.

5. Your program should be written in C (not C++), and compiled with the (gcc) compiler under Linux.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!