PROBLEM: Create a program that will ask to fill in two square matrices and perform matrix multiplication. Output the resulting matrix in proper format. SPECIFICATIONS that you need to follow: - The maximum size of the square matrices is 10x10. Matrices 1 and 2 should have the same dimensions. - You may only use the codes that we studied under our lectures - All lines of codes should have a comment. - Save your cpp file as Surname_FE (Example: Pangaliman_FE.cpp)
PROBLEM:
Create a program that will ask to fill in two square matrices and perform matrix multiplication. Output the resulting matrix in proper format.
SPECIFICATIONS that you need to follow:
- The maximum size of the square matrices is 10x10. Matrices 1 and 2 should have the same dimensions.
- You may only use the codes that we studied under our lectures
- All lines of codes should have a comment.
- Save your cpp file as Surname_FE (Example: Pangaliman_FE.cpp)
TEST CASES:
If a user inputs n = 2:
Input:
Input dimension (nxn) of the matrix, n = 2
Input Matrix 1 elements: 1 2 3 4
Input Matrix 2 elements: 5 6 7 8
Result:
Resultant matrix:
19 22
43 50
If a user inputs n = 10:
Input:
Input dimension (nxn) of the matrix, n = 10
Input Matrix 1 elements:
-35 54 64 31 45 -12 17 -31 -19 -78
-35 54 3 -10 -11 90 -41 31 -30 0
22 -53 21 -13 -64 32 -70 57 58 86
-77 30 73 24 -77 -90 -26 85 48 -47
-96 58 70 -59 82 -97 43 51 45 62
63 40 67 42 52 -78 -69 -91 -79 -45
35 77 -24 99 -17 0 78 31 56 -47
-97 -6 89 76 5 -100 -24 98 -46 76
-4 6 -63 64 50 -1 23 60 13 -13
77 -42 62 45 -82 -35 93 97 11 92
Input Matrix 2 elements:
69 90 -85 29 52 -19 37 -26 -97 23
92 96 -6 -52 -61 -91 -78 83 -22 98
63 -4 90 72 -1 11 -12 -8 39 -75
72 -92 72 -80 -77 -60 -53 62 -86 -23
48 65 14 13 90 95 99 5 84 74
-19 -4 2 -87 54 -63 -51 -26 -6 -93
-99 -55 -6 -24 -83 35 50 54 0 2
37 -55 26 -9 80 73 37 -86 -91 -99
24 56 84 43 51 -50 -60 57 -44 26
94 -98 -69 98 -4 -31 59 -63 -66 -25
Result:
Resultant matrix:
587 9249 14127 -8656 -8711 1326 -6610 14754 14694 7979
4270 737 759 -11365 3876 -8003 -9795 -4237 219 -8623
11864 -10749 -590 14419 14309 -6535 -2380 -17891 -18014 -20101
4241 -7146 23046 3689 -7951 803 -14178 4334 -5081 -8230
9191 -932 11388 19985 643 15813 12271 2619 12597 9329
16588 17856 -1452 3341 -7399 -479 575 8470 11573 18422
4650 2172 9578 -17207 -12956 -11841 -12439 19425 -18150 6334
18016 -30023 15217 11756 -8387 11841 7048 -8485 -4414 -14418
2367 -4729 3351 -11154 2613 4748 3572 2992 -8673 2311
8618 -25530 -2151 13644 -5997 1690 9670 -11183 -30058 -22274
If a user inputs n = 12:
Input:
Input dimension (nxn) of the matrix, n = 12
Result:
Invalid input!
If a user inputs n <=0:
Input:
Input dimension (nxn) of the matrix, n = -4
Result:
Invalid input!
If a user inputs n = 1:
Input:
Input dimension (nxn) of the matrix, n = 1
Result:
Invalid input!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 4 images