### Using sequences for a matrix to add and subtract

I'm trying to use a set of sequences to add and subtract a matrix that is loaded into the program from a txt file, but I've got a mistake at the beginning of the code in the int main () section that I can't figure out. I'm not sure on how to reference to the separate add and subtract sequences like I have for the fill and print sequences. I've included notes within the code. This is for a school project and I have to use the sequence set up. I think that I am close, but unsure of where to fix the problem. Any help or advice would be greatly appreciated.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106`` ``````#include #include #include #include void Fill(double[3][3], int, int); void Print(double[3][3], int, int); void Add(double[3][3], int, int); void Subtract(double[3][3], int, int); using namespace std; ifstream infile; int main() { double A[3][3], B[3][3], mat1, mat2, mat3; infile.open("in.txt"); //loads data from in.txt for matrix a and b Fill(A, 3, 3); Fill(B, 3, 3); cout << "Matrix A: " << endl; Print(A, 3, 3); //shows matrix a cout << endl; cout << "Matrix B: " << endl; Print(B, 3, 3); //shows matrix b cout << endl; //for lines 36 to 49 are my issue //issue with this section of code, trying to load the code from in.txt //to add and subtract matrix a and b //add matrix a to matrix b Fill(A, 3, 3); Fill(B, 3, 3); cout << "Matrix A+B: " << endl; Add(mat1,mat2,3,3); cout <<"A +B" << endl; Print(mat3, 3, 3); cout << endl; //subtract matrix b from a Fill(A, 3, 3); Fill(B, 3, 3); cout << "Matrix A-B: " << endl; //Print(); cout << endl; infile.close(); } //loads matrix a and b from in.txt void Fill(double mat[3][3], int m, int n) { int i, j; for(i=0; i> mat[i][j]; } } } //prints matrix a and b from in.txt void Print(double mat[3][3], int m, int n) { int i, j; for(i=0; i
what is M and N? I suspect they are both 3, given that the matrices are 3x3. In that case, use 3 and lose the extra parameters.

add takes 3 matrices, but you only provided 2.
 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576`` ``````#include #include #include using namespace std; constexpr size_t ArrSze {3}; using Array = double[ArrSze][ArrSze]; void Fill(ifstream&, Array); void Print(const Array); void Add(const Array, const Array, Array); void Subtract(const Array, const Array, Array); int main() { Array A{}, B{}, mat1{}, mat2{}; ifstream infile("in.txt"); if (!infile) return (std::cout << "Cannot open file\n"), 1; Fill(infile, A); Fill(infile, B); cout << "Matrix A:\n"; Print(A); cout << '\n'; cout << "Matrix B:\n"; Print(B); cout << '\n'; cout << "Matrix A + B:\n"; Add(A, B, mat1); cout << "A + B\n"; Print(mat1); cout << '\n'; cout << "Matrix A - B:\n"; Subtract(A, B, mat2); cout << "A - B\n"; Print(mat2); cout << '\n'; } void Fill(ifstream& infile, Array mat) { for (size_t i = 0; i < ArrSze; ++i) for (size_t j = 0; j < ArrSze; ++j) infile >> mat[i][j]; } void Print(const Array mat) { for (size_t i = 0; i < ArrSze; ++i) { for (size_t j = 0; j < ArrSze; ++j) cout << mat[i][j] << " "; cout << '\n'; } } void Add(const Array mat1, const Array mat2, Array mat3) { for (size_t i = 0; i < ArrSze; ++i) for (size_t j = 0; j < ArrSze; ++j) mat3[i][j] = mat1[i][j] + mat2[i][j]; } void Subtract(const Array mat1, const Array mat2, Array mat3) { for (size_t i = 0; i < ArrSze; ++i) for (size_t j = 0; j < ArrSze; j++) mat3[i][j] = mat1[i][j] - mat2[i][j]; }``````