#include <iostream>
#define max 100
using namespace std;
int main()
{
int a[max][max], b[max][max], c[max][max], arow, acol, brow, bcol, sum = 0;
cout << “Enter the row of matrix A : “;
cin >> arow;
cout << “Enter the col of matrix A : “;
cin >> acol;
cout << “Enter the row of matrix B : “;
cin >> brow;
cout << “Enter the col of matrix B : “;
cin >> bcol;
if (arow == brow && acol == bcol)
{
// input matrix A
for (int i = 0; i < arow; i++)
{
for (int j = 0; j < acol; j++)
{
cout << “Enter the element at index A[” << i << “][” << j << “] : “;
cin >> a[i][j];
}
}
// input matrix B
for (int i = 0; i < brow; i++)
{
for (int j = 0; j < bcol; j++)
{
cout << “Enter the element at index B[” << i << “][” << j << “] : “;
cin >> b[i][j];
}
}
cout << endl;
// print matrix A
for (int i = 0; i < arow; i++)
{
for (int j = 0; j < acol; j++)
{
cout << a[i][j] << ” “;
}
cout << endl;
}
cout << endl;
// print matrix B
for (int i = 0; i < brow; i++)
{
for (int j = 0; j < bcol; j++)
{
cout << b[i][j] << ” “;
}
cout << endl;
}
//adddition
for (int i = 0; i < brow; i++)
{
for (int j = 0; j < bcol; j++)
{
c[i][j] = a[i][j] + b[i][j];
}
}
cout<<“\nAddition of matrix A and B\n”;
//adddition
for (int i = 0; i < brow; i++)
{
for (int j = 0; j < bcol; j++)
{
cout<< c[i][j] <<” “;
}
cout << endl;
}
}
else
{
cout << “Matrix Addition is not possible”;
}
return 0;
}