#include<iostream>
using namespace std;
int main() {
    int r,c,a[2][2],b[2][2],sum[2][2];
    
    cout<<"enter the no. of rows\n";
    cin>>r;
    
    cout<<"enter the no. of columns\n";
    cin>>c;
    
    cout<<"enter the elements of first matrix\n";
    for(int i=0;i<c;i++) {
        for(int j=0;j<c;j++){
            //cout<<"enter matrix a";
            cin>>a[i][j];
        }
    }
            cout<<"enter the elements of second matrix\n";
            for(int i=0; i<r;i++){
                for(int j=0; j<c; j++) {
                    //cout<<"enter matrix b";
                    cin>>b[i][j];
                }
            }
           
           for(int i=0;i<r;i++) {
               for(int j=0;j<c;j++){
                 sum[i][j] =a[i][j]+b[i][j];
               }
           }
           cout<<"sum of the matrix is";
           for(int i=0;i<r;i++){
               for(int j=0;j<c;j++){
                   cout<<sum[i][j];
               }
           }
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: