Question: Write a C++ program to add two matrices. DO NOT USE STL OR VECTORS. Read two text files (1.txt, 2.txt), each with one matrix. The

Write a C++ program to add two matrices. DO NOT USE STL OR VECTORS. Read two text files (1.txt, 2.txt), each with one matrix. The output (3.txt) will be a text file with one matrix. Output should be one row per line with values as 2 decimals separated by one space. Given matrix A and B of size m x n you will compute matrix C = A + B. The number of column and row in the smaller column and row determines matrix size m n.

Determine matrix size based on # of columns of 1st row of the input matrix.

example of outputs

matrix A (1.txt) 1 0 0 1

matrix B (2.txt) 1 0 0 1

matrix C (3.txt) 2.00 0.00 0.00 2.00

--- matrix A (1.txt) 0.5 3.0 0.0 0.0 0.0 1.0 0.8 0.8 1.0 0.0 0.2 0.2

matrix B (2.txt) 1.0 6.0 0.0 0.0 2.0 1.6 2.0 0.0 0.4

matrix C (3.txt) 1.50 9.00 0.00 0.00 3.00 2.40 3.00 0.00 0.60

---

matrix A (1.txt) 0.5 3.0 0.0 0.0 0.0 1.0 0.8 0.8

matrix B (2.txt) 1.0 6.0 0.0 2.0 2.0 0.0

matrix C (3.txt) 1.50 9.00 0.00 3.00

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!