CJCoding With Joseph
15free / daySign inCreate account

2x2 Matrix Multiply

A 2x2 matrix is an array<array<int, 2>, 2>, where m[r][c] is the value in row r, column c.

Write a function array<array<int, 2>, 2> multiply(const array<array<int, 2>, 2>& a, const array<array<int, 2>, 2>& b) that returns the matrix product a x b.

The test prints the result as two lines, the two values in each row separated by a space. For a = {{1, 2}, {3, 4}} and b = {{5, 6}, {7, 8}} it prints the output shown in Expected Output.

Do NOT write a main function.

Expected Output:

19 22
43 50
2 4
6 8

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
STL Containersstd::array
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.