Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program in C++ that adds matrices from the input file below. must have a

ID: 3725429 • Letter: W

Question

Write a program in C++ that adds matrices from the input file below. must have a main.cpp file, matrix.h and matrix.cpp file.

matrix must me max of 50. Update to question: the 2 3 is the size of the matrix and then the 123 and 321 are the first matrix and the 456 789 are the second matrix to be added together.


2 3
1 2 3
3 2 1

4 5 6
7 8 9

4 5
81 47 29 78 75
5 37 43 37 7
3 4 4 71 5
12 46 45 46 28

31 91 61 78 39
42 29 36 72 92
26 70 23 57 23
90 91 75 6 87

3 3
3 99 22
88 90 9
92 81 75

38 27 95
94 40 63
88 51 24

Explanation / Answer

#include<iostream>
using namespace std;

int main()
{
int row, col, m1[50][50], m2[50][50], sum[50][50];

cout<<"Enter the number of rows(should be >1 and <50): ";
cin>>row;
cout<<"Enter the number of column(should be >1 and <50): ";
cin>>col;
cout << "Enter the elements of first 1st matrix: ";
for (int i = 0;i<row;i++ ) {
for (int j = 0;j < col;j++ ) {
cin>>m1[i][j];
}
}
cout << "Enter the elements of first 1st matrix:";
for (int i = 0;i<row;i++ ) {
for (int j = 0;j<col;j++ ) {
cin>>m2[i][j];
}
}

cout<<"Output: ";
for (int i = 0;i<row;i++ ) {
for (int j = 0;j<col;j++ ) {
sum[i][j]=m1[i][j]+m2[i][j];
cout<<sum[i][j]<<" ";
}
cout<<" ";
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote