C++ Addition of two Matrices using 2 Dimensional Array - 6 Players blogs for technology

give us your feedback

People Online

Breaking

ads

Post Top Ad

Monday, October 14, 2019

C++ Addition of two Matrices using 2 Dimensional Array

#include <iostream>

using namespace std;

int main()
{
    //Two Dimensional Array

    int a[50][50],b[50][50],c[50][50];
    int c1,r1,m,n;
    cout<< "Enter the number of columns : ";
    cin>>c1;
    cout<< "Enter the number of rows : ";
    cin>>r1;
    cout<< "Enter the element of of First Array : "<<endl;
    for(n=0;n<c1;n++){
            for(m=0;m<c1;m++){
        cin>>a[n][m];

    }}
    cout<< "Enter the element of of Second Array : "<<endl;
    for(n=0;n<r1;n++){
            for(m=0;m<r1;m++){

        cin>>b[n][m];

    }}
    cout<< "The sum of two Matrices are : "<<endl;
    for (n=0;n<c1;n++){
            for(m=0;m<r1;m++){
        c[n][m]=a[n][m]+b[n][m];

    cout<<a[n][m]<< " + "<<b[n][m]<< " = "<<c[n][m]<<endl;
    }}

    return 0;
}

No comments:

Post a Comment

ads1

Post Top Ad