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
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