Question
Language is C++ I'm having trouble getting my program to add matrixes together. The output ends up completely wrong. Could you help me modify my
Language is C++
I'm having trouble getting my program to add matrixes together. The output ends up completely wrong. Could you help me modify my code and get it working.
Please provide a picture of the code's output working using the Matrix_Addition text files I have provided below
My Code to use:
#include
int** theTable1; int** theTable2; int** theSum;
int main() {
int numRows, numCols;
string fileName1, fileName2; cout
ifstream fin1, fin2; fin1.open(fileName1); fin2.open(fileName2);
if (!fin1 || !fin2) { cout
fin1 >> numRows >> numCols; theTable1 = new int* [numRows]; for (int i = 0; i > theTable1[r][c]; } }
fin2 >> numRows >> numCols; theTable2 = new int* [numRows]; for (int i = 0; i > theTable2[r][c]; } }
theSum = new int* [numRows]; for (int i = 0; i
cout
cout
cout
The Assignment:
Matrix_Addition1.txt
4 5 231 45 -45.565 45 0 823 -267 56 454 -1 9 53 -5.555 23 456 -.1 32 1.2345 3.14159 8
Matrix_Addition2.txt
4 5 1.111 2.222 3.333 4.444 5.555 -11 -12 -14 -16 -18 8 2 2 645 25 37 -37 45 2.535 10
My code's current output that is wrong:
A "matrix" is expressed as a two-dimensional array. In matrix addition, the two arrays must have exactly the same dimensions. Each element of the "sum" array is the sum of that element in the other two arrays. For example The data file format for the arrays will be the row and column dimensions, followed by the data. For example, the file containing the first array would be 33 123 456 789 Submit your Matrix Addition program here. Also provide a screen shot showing your program in action, using the input files provided on Moodle. The program should display the two matrices read from the files, then display their sum. Be sure that your output is formatted appropriately
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started