Question: Language is C++ 2. Matrix Arithmetic We are going to write a program to perform arithmetic on matrices, specifically to add and subtract them. While

Language is C++
2. Matrix Arithmetic We are going to write a program to perform arithmetic on matrices, specifically to add and subtract them. While a 2D array is a more suitable representation for a matrix, there are peculiarities with passing a 2D array to a function. We will therefore simulate the 2D structure of the matrix with a regular (10) array. Function Description You have to write the following functions. print_matrix prints the contents of the matrix passed to it. input_matirx. populates the matrix passed to it with values input form the console. add_matrices takes 3 matrices as parameters and stores the sum of the first 2 matrices in the third one subtract_matrices. takes 3 matrices as parameters and stores the difference of the first 2 matrices in the third one You may pass any additional parameters to your functions as needed. Input Format For Custom Testing The first line contains 2 integers, rand c denoting the dimension of the 2 matrices that follow. Both matrices will have rrows and columns. Each of the next rlines contains cspace separated integers corresponding to a row of the first matrix. Each of the next rlines contains cspace separated integers corresponding to a row of the second matrix. The next line contains a single character, either + or - Depending on the character, you have to output the sum or the difference respectively of the matrices
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
