Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This program populates a two-dimensional array of integers, then asks the user what the row and column spacing should be before writing the matrix to

This program populates a two-dimensional array of integers, then asks the user what the row and column spacing should be before writing the matrix to stdout. I have part of the program set up already. // Sample runs: // Run #1: // What field width do you want to use? 3 // What row height do you want to use? 2 // 0 1 2 3 4 // // 5 6 7 8 9 // // 10 11 12 13 14 // // Run #2: // What field width do you want to use? 5 // What row height do you want to use? 1 // 0 1 2 3 4 // 5 6 7 8 9 // 10 11 12 13 14 // // Run #3: // What field width do you want to use? 4 // What row height do you want to use? 0 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14

-------------------------------------------------------------------------

#include

#include

#include

using namespace std;

// defined constants

const int ROWS = 3;

const int COLS = 5;

// function prototypes

? ? ?

? ? ?

// ==== main ==================================================================

//

// ============================================================================

int main()

{

int myInts[ROWS][COLS];

int userHeight;

int userWidth;

// intialize the 2D array

InitMatrix(myInts, ROWS);

// get the field width from the user

cout

if (!(cin >> userWidth))

{

cerr

exit(EXIT_FAILURE);

}

// get the row height from the user

cout

if (!(cin >> userHeight))

{

cerr

exit(EXIT_FAILURE);

}

// display the 2D array

DispMatrix(myInts, ROWS, userHeight, userWidth);

return 0;

} // end of "main"

// ==== DispMatrix ============================================================

//

// This function writes the two-dimensional array parameter to stdout in row /

// column format. It uses the height and width parameters to provide row and

// column spacing, respectively.

//

// Input:

// matrix [IN] -- the base address of a two-dimensional array of integers

//

// numRows [IN] -- the number of rows in the matrix parameter

//

// height [IN] -- the number of rows each one-dimensional array should

// occupy

//

// width [IN] -- the field width for each integer displayed

//

// Output:

// Nothing

//

// ============================================================================

void DispMatrix(? ? ? )

{

? ? ?

} // end of "DispMatrix"

// ==== InitMatrix ============================================================

//

// This function initializes the two-dimensional array parameter with

// sequentially increasing integer values, beginning with zero.

//

// Input:

// matrix [OUT] -- the base address of a two-dimensional array of integers

//

// numRows [IN] -- the number of rows in the matrix parameter

//

// Output:

// Nothing

//

// ============================================================================

void InitMatrix(? ? ? )

{

? ? ?

} // end of "InitMatrix"

image text in transcribedimage text in transcribedimage text in transcribed

include #include using namespace std; // defined constants const int const int ROWS3 COLS = 5; // function prototypes int main() int int int myInts[ROWS][COLS]; userHeight userwidth // intialize the 2D array InitMatrix(myInts, ROWS) // get the field width from the user cout > userwidth)) cerr

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

Logistics Lifeline Supply Chain Strategies

Authors: Ehsan Sheroy

1st Edition

7419377502, 978-7419377503

More Books

Students also viewed these Databases questions