#include<iostream>
using namespace std;
int main()
{
int a[20][20],b[20][20],sum[20][20],r,c;
cout<<"Enter number of rows for arry :"<<endl;
cin>>r;
cout<<"Enter number of colums for arry :"<<endl;
cin>>c;
// input in table A
for(int i=0; i<r; i++)
{
for(int j=0; j<c; j++)
{
cout<<"Enter value of a"<<i+1<<j+1<<endl;
cin>>a[i][j];
}
}
// input in table B
for(int i=0; i<r; i++)
{
for(int j=0;j<c;j++)
{
cout<<"Enter Value of b"<<i+1<<j+1<<endl;
cin>>b[i][j];
}
}
// Add table A and B
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
sum[i][j]=a[i][j]+b[i][j];
}
}
// Show Output
for(int i=0; i<r;i++)
{
for(int j=0;j<c;j++)
{
cout<<"Sum of a"<<i<<j<<"+ b"<<i<<j<<" :"<<sum[i][j]<<endl;
}
}
return 0;
}
No comments:
Post a Comment