Skip to content

Commit

Permalink
Merge pull request #70 from MonalikaKapoor/Addition-of-two-matrices
Browse files Browse the repository at this point in the history
Added code for Addition of two matrices using array
  • Loading branch information
unnati914 authored Nov 17, 2021
2 parents 7ecf150 + 876c536 commit cb74c0f
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions Addition of two matrices ussing array.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* C++ Program to Add Two Matrices using array */

#include<iostream>
using namespace std;

int main()
{

int arr1[5][5], arr2[5][5], arr3[5][5], sub, i, j,m,n;

cout<<"Enter size of matrix ( Max:5 ) :: ";
cin>>m;
cout<<"\nEnter Elements to Matrix A Below :: \n";

for(i=0;i<m;i++)
{
for(j=0;j<m;++j)
{
cout<<"\nEnter arr1["<<i<<"]["<<j<<"] Element :: ";
cin>>arr1[i][j];
}

}

cout<<"\nEnter Elements to Matrix B Below :: \n";

for(i=0;i<m;i++)
{
for(j=0;j<m;++j)
{
cout<<"\nEnter arr2["<<i<<"]["<<j<<"] Element :: ";
cin>>arr2[i][j];
}

}


cout<<"\nAdding Matrix ( A + B ) ..... \n";
for(i=0; i<m; i++)
{
for(j=0; j<m; j++)
{
arr3[i][j]=arr1[i][j]+arr2[i][j];
}
}

cout<<"\nAfter Addition, Matrix C is :: \n";

for (i = 0; i < m; ++i)
{
for (j = 0; j < m; ++j)
{
cout<<"\t"<<arr3[i][j];
}
printf("\n\n");
}

return 0;
}

0 comments on commit cb74c0f

Please sign in to comment.