//WAP TO ADD 2 MATRICES
#include<iostream>
using namespace std;
main()
{
int i,j,n;
cout<<"Enter the Size of the Matrix"<<endl;
cin>>n;
int a[n][n],b[n][n],c[n][n];
cout<<"Enter the elements of the Matrix a"<<endl;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
cin>>a[i][j];
}
cout<<"Enter the elements of the Matrix b"<<endl;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
cin>>b[i][j];
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
c[i][j]=a[i][j]+b[i][j];
}
cout<<"The Sum of the Two Matrices:"<<endl;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
cout<<c[i][j]<<" ";
cout<<endl;
}
}
No comments:
Post a Comment