write a c++ program for Ashok is a ninth-grade schoolboy. Miss Sumaiya is a very strict teacher and she teaches math to all the students. On the first day of the academic year, Miss Sumaiya gave him homework to find the addition of two matrices. Can you help Ashok by writing a program for the same.
Answers
Answer:
void do it urself!!
Explanation:
The C++ program to find the addition of two matrices is as follows:
#include<iostream>
using namespace std;
int main()
{
int rows, cols, m1[10][10], m2[10][10], sum[10][10];
cout<<"Enter the number of rows(should be >1 and <10): ";
cin>>row;
cout<<"Enter the number of columns(should be >1 and <10): ";
cin>>col;
cout << "Enter the elements of first matrix: ";
for (int i = 0;i<rows;i++ ) {
for (int j = 0;j < cols;j++ ) {
cin>>m1[i][j];
}
}
cout << "Enter the elements of first matrix: ";
for (int i = 0;i<rows;i++ ) {
for (int j = 0;j<cols;j++ ) {
cin>>m2[i][j];
}
}
cout<<"Output: ";
for (int i = 0;i<rows;i++ ) {
for (int j = 0;j<cols;j++ ) {
sum[i][j]=m1[i][j]+m2[i][j];
cout<<sum[i][j]<<" ";
}
}
return 0;
}