Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

HW11: Matrices Here's an assignment that'll give you some practice with arrays, specifically 2D arrays. All you have to do is write a program that

HW11: Matrices

Here's an assignment that'll give you some practice with arrays, specifically 2D arrays. All you have to do is write a program that allows the user to populate two 2D arrays of integers (3 x 3 matrix) by calling the functionInitMatrix. After the user has entered all the values, then call the functionDispMatrixto display the two matrices. Then you can call the functionsAddMatrices,TMatrix, andDetMatrixto calculate the addition of the matrices, the transpose of each matrix, and the determinant of each matrix respectively.

InitMatrixwill take as argument a 2D array and the number of rows and have a void return type. It will prompt the user to enter 9 total values for a 3 x 3 matrix.

DispMatrixwill take as argument a 2D array and the number of rows and have a void return type. It will display the contents of the a 2D array. Hint: I suggest you use thesetw()function to display the matrices nicely.

AddMatrixwill take as argument two 2D arrays and the number of rows and have a void return type. It will add two 2D arrays and callDispMatrixto output the result.

TMatrixwill take as argument a 2D array and the number of rows and have a void return type. It will switch the rows and columns and callDispMatrixto output the result.

DetMatrixwill take as argument a 2D array and the number of rows and have an int return type. It will calculate the determinate of a 2D array and return the result as an int.

Here's a sample run:

Please enter 9 integer values for the first matrix: [0][0]: 6 [0][1]: 1 [0][2]: 1 [1][0]: 4 [1][1]: -2 [1][2]: 5 [2][0]: 2 [2][1]: 8 [2][2]: 7

Please enter 9 integer values for the second matrix:

[0][0]: 12 [0][1]: 4 [0][2]: 11 [1][0]: -3 [1][1]: 7 [1][2]: -9 [2][0]: 4 [2][1]: 8 [2][2]: 21

The matrices you've entered are:

6 1 1 4 -2 5 2 8 7

12 4 11 -3 7 -9 4 8 21

The sum of the matrices are:

18 5 12 1 5 -4 6 16 28

The transpose of the matrices are:

6 4 2 1 -2 8 1 5 7

12 -3 4 4 7 8 11 -9 21

The determinant of the matrices are: -306 and 2164

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

More Books

Students also viewed these Databases questions