1. Engineering
  2. Computer Science
  3. c program i need 4 functions with each of the...

Question: c program i need 4 functions with each of the...

Question details

C PROGRAM

I need 4 functions with each of the following properties and functionality

Use malloc() only once!! And explain important parts of the code!!

Int *Array2D (int rows, int cols)

this function takes two parameters that are the number of rows and columns. It returns a pointer to the data structure that has been dynamically allocated so it has enough space to hold the array

Void setElementIn2DArray(int *array, int row, int col int value)

this function places a value in the array. The parameters are:

the data structure allocated using the Array2D()

-the row location where the value is stored

-the column location where the value is stored

-the value to be placed in the array

Int get2Delement(int *array, int row, int col)

this function returns a value from the array

-the data structure allocated using array2D()

-the row location where the value is stored

-the column location where the value is stored

Void free2DArray(int *array)

this function frees the memory allocated by array2D. The parameter is the data structure allocated.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution