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
- 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)
- Write the function sumOfEvenNumbersGreaterThan9().
- Show/Write the input 2D array in a matrix form based on the given code snippets.
- Output or results that sumOfEvenNumbersGreaterThan9() will return.
NEED IT NOW PLEASE
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
