Question: Consider the following code snippets related to 2D Array. You need to implement the function sumOfEvenNumbersGreaterThan9 , whose arguments are number of rows, columns, and

  1. Consider the following code snippets related to 2D Array. You need to implement the function sumOfEvenNumbersGreaterThan9, whose arguments are number of rows, columns, and 2D Array. The function will sum all the even numbers greater than 9 from the 2D array. Finally, return the result to the main function.

int main()

{

int row = 3, col = 4;

//Dynamically create array of pointers of size row (ex 4)

int** A = new int* [row];

// Dynamically allocate memory of size col (5) for each row

for (int i = 0; i < row; i++)

A[i] = new int[col];

// Assign values to allocated memory

for (int i = 0; i < row; i++)

for (int j = 0; j < col; j++)

A[i][j] = j + 9;

int sum = sumOfEvenNumbersGreaterThan9(row, col, A);

cout << "In main sum is " << sum << endl;

}

a)

  1. Write the function sumOfEvenNumbersGreaterThan9().
  2. Show/Write the input 2D array in a matrix form based on the given code snippets.
  3. Output or results that sumOfEvenNumbersGreaterThan9() will return.

NEED IT NOW PLEASE

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!