C++ program
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 function InitMatrix. After the user has entered all the values, then call the function DispMatrix to display the two matrices. Then you can call the functions AddMatrices, TMatrix, and DetMatrix to calculate the addition of the matrices, the transpose of each matrix, and the determinant of each matrix respectively.
InitMatrix will 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.
DispMatrix will take as argument a 2D array and the number of rows and have a void return type. It will display the contents of the 2D array. Hint: I suggest you use the setw() function to display the matrices nicely.
AddMatrix will take as argument two 2D arrays and the number of rows and have a void return type. It will add two 2D arrays and call DispMatrix to output the result.
TMatrix will 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 call DispMatrix to output the result.
DetMatrix will 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
We can write this or a similar paper for you! Simply fill the order form!