Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// write the required preprocessor directives #include using namespace std ; // declare an integer constant named COLUMNS and initialize to 5 const int COLUMNS

// write the required preprocessor directives

#include

using namespace std;

// declare an integer constant named COLUMNS and initialize to 5

const int COLUMNS = 5;

// The following methods receive a two dimension integer

// array and the size of the first dimension as parameters

void fillTwoDim(int[][COLUMNS], const int);

int addTwoDim(int[][COLUMNS], const int);

float average(int[][COLUMNS], const int);

void printTwoDim(int[][COLUMNS], const int);

void personalInfo(); // This method has no parameters or return value

int main(){

// declare an integer constant named ROWS and initialize to 3

const int ROWS = 3;

// declare a two dimension intger array named numbers using the

// constants as the size and initialize all elements to 0

int numbers [ROWS][COLUMNS] = { 0 };

// call the printTwoDim method

printTwoDim (numbers, ROWS);

// call the fillTwoDim method to populate the array

fillTwoDim (numbers, ROWS);

// call the printTwoDim method

printTwoDim (numbers, ROWS);

// print the phrase "The average of all values in the array is [average]."

// Call the appropriate function to obtain the average value.

cout << "The average of all values in the array is: " << average(numbers, ROWS)<< "."<< endl;

// call the personalInfo method

personalInfo();

return 0;

}

// The fillTwoDim method receives a two dimension integer array and the size of the

// first dimension as parameters and has no return value. If uses the pseudo random

// number generator function to assign a value between 0 and 500 to every element of

// the array. Make sure to seed the pseudo random number generator before calling the

// rand function. The only variables declared in this method are the counters used in

// the for iteration control structures.

void fillTwoDim (int[][COLUMNS], const int){

}

// The addTwoDim method receives a two dimension integer array and the size of the

// first dimension as parameters and returns an integer value. Declare the local integer

// variable suma and initialize it to 0. The method implements a nested for iteration

// control structure to add all values in the array and returns the sum.

// The average method receives a two dimension integer array and the size of the

// first dimension as parameters and returns a float value. Call the addTwoDim method

// to obtain the sum and return the average value.

// NO VARIABLES ARE DECLARED IN THIS METHOD

// The printTwoDim method receives a two dimension integer array and the size of the

// first dimension as parameters and has no return value. It prints the contents of

// the array in a matrix format where a tab space is inserted before each value.

// First, print the phrase "The values stored in the two-dimension array are:"

// Then print the contents of the array using the tab space as described above.

// Make sure to add a blank line after all values are printed.

// The personalInfo method prints a statement with your personal information using

// the phrase "***** Program developed by [YOUR NAME], ID# [YOUR ID NUMBER] *****"

// where the square brackets and the text within is substituted with your personal

// information. Make sure to add a blank line after the phrase is printed.

void personalInfo(){

cout << "***** Program developed by, ID# *****"<< endl;

}

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions