Header Ads Widget

Responsive Advertisement

Ticker

6/recent/ticker-posts

Addition

 Addition - Data Structure


#include<iostream>

using namespace std;


int main()

{

    int a[50][50],b[50][50],result[50][50];


    int r,c;

    cout<<"Enter the number of row: ";

    cin>>r;

    cout<<"Enter the number of column: ";

    cin>>c;


    cout<<"Enter elements of Matrix A: ";

    for(int i=0; i<r; i++)

        for(int j=0; j<c; j++)

            cin>>a[i][j];


    cout<<"Enter elements of Matrix B: ";

    for(int i=0; i<r; i++)

        for(int j=0; j<c; j++)

            cin>>b[i][j];


    for(int i=0; i<r; i++)

        for(int j=0; j<c; j++)

            result[i][j] = a[i][j] + b[i][j];


    cout<<"Your Matrix is :"<<endl;

    for(int i=0; i<r; i++)

    {

        for(int j=0; j<c; j++)

            cout<<result[i][j]<<"  ";

        cout<<endl;

    }

}


Post a Comment

0 Comments