C++ Problem For this project, you will simply tinker with a 2-Dimensional integer array. You will write a main program t

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

C++ Problem For this project, you will simply tinker with a 2-Dimensional integer array. You will write a main program t

Post by answerhappygod »

C++ Problem
For this project, you will simply tinker with a 2-Dimensional
integer array. You will write a main
program that tests the functions below. You should continue looping
until the user enters 0 (for quit). Be
sure the functions work (or do not crash), even if the Fill
function has not yet been called.
1. Fill the matrix: This function will have as parameters the
matrix, and the row and column sizes for
the matrix. The three parameters will all be modified in this
function. This function will open the
input file p8in.txt. Should there be a file error, an appropriate
message should be printed and the
program should terminate. The first two items in the array are the
row and column counts,
respectively. The file will then contain row * col numbers in the
array. See the sample file for a
2x3 matrix below:
2 3
10 20 30
40 50 60
2. Print the matrix in row major: This function will take in as
parameters a matrix, the row size, and
the column size. Print the contents of the matrix in tabular form.
Row major form should be used.
3. Print the matrix in column major: This function will take in
as parameters a matrix, the row size,
and the column size. Print the contents of the matrix in tabular
form. Column major form should
be used.
4. Get Sum: This function will take in as parameters a matrix, the
row size, and the column size. It
will return the sum of the contents of the matrix. (Note: no output
should be inside the function,
but the main should output the results of this function).
5. GetStats: This function will take in as parameters a matrix, the
row size, and the column size. It
will pass back as parameters the average, the min, and the max.
(Note: no output should be inside
the function, but the main should output the 3 values calculated
inside the function)
6. Print Diagonal: This function will take in as parameters a
matrix, a row size, and the column size.
If the matrix is a square matrix (row == col), then the values of
the diagonal will be printed,
otherwise, an appropriate error message will be printed.
7. Print Column Products: This function will take in as parameters
a matrix, a row size, and the column
size. For each column, print the column index and the product of
the column.
8. Menu: This function will as the user for the choice of
activities to occur. You should use the
numbers above as the choices for the respective functions to
display to the user. 0 should be the
option for “quit”.

Special Considerations:
 You may assume the row and columns sizes for the matrices defined
in the testing input files will be
no more than 10. Therefore, you should set global constants ROW and
COL to 10.
 Remember, the column size must be specified in function
prototypes, use the constant COL for this.
Note, depending upon the file inputs, you may have smaller than
10x10 matrices.
 If a function description states that it “takes in as
parameters”, you may assume the information
was gathered in the main. You will not do input of those values
inside the function. It is understood
the function is called with that information given as
parameters
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply