Question: Given that arrayIntValues [MAX_ROWS][MAX_COLUMNS] is a 2 dimensional array of positive integers, write a C++ function howManyEven to find the total number of even elements

Given that arrayIntValues [MAX_ROWS][MAX_COLUMNS] is a 2 dimensional array of positive integers, write a C++ function howManyEven to find the total number of even elements in the array. It should have input parameter array arrayIntValues. The function should return an integer. Also create a C++ subroutine called printArray with the input parameter array arrayIntValues to print out the elements in the array (be sure to have row and column labels and proper formatting (i.e. column values line up?) The constants MAX_ROWS and MAX_COLUMNS must be accessed globally by defining the following global variables: #define MAX_ROWS 3 #define MAX_COLUMNS 2 The array arrayIntValues is initialized by the following statement in your main(): int arrayIntValues [MAX_ROWS][ MAX_COLUMNS] = { {3 , 2}, {4, 5}, {2, 2} }; Print out the array and the number of positive even numbers (label appropriately). User enters a new set of values into the array (must do it at least once) as many times as they wish and run howManyEven against the new array values. Be sure to edit for input to be a positive integer. Then print new array values and number of positive integer numbers. Be sure to check for valid input (y or n) when asking if the user wants to enter a new set of values. Then read in from a data file inFilePgm2A.dat additional data scenarios for testing .. a value of -1 indicates the end of the data for that test (i.e. assume -1 exists in the file except empty file condition). Be sure to account for all the standard file checks (file doesnt exist, file empty (should always contain at least a -1)) and handle the issues of not enough or too much data for the array, a complete (right number of data values) but array contains a non-positive number - still print the array but also print an error message (do not calculate number of even values).

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!