Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions