C++ Program to Perform Matrix Addition Operation using Array

SOURCE CODE:
#include<iostream.h>
#include<conio.h>
void main()
{
 int a[5][5],b[5][5],c[5][5],i,j,m,n;
 clrscr();
 cout<<"\nEnter the Number of rows and columns: ";
 cin>>m>>n;

 cout<<"\nEnter the A matrix:";
 for(i=0;i<m;i++)
  {
   for(j=0;j<n;j++)
    {
     cin>>a[i][j];
    }
  }
 cout<<"\nEnter the B matrix:";
  for(i=0;i<m;i++)
  {
   for(j=0;j<n;j++)
    {
     cin>>b[i][j];
    }
  }
  cout<<"\nTHE ADDITION OF THE MATRICES IS........\n\n";
   for(i=0;i<m;i++)
    {
     for(j=0;j<n;j++)
      {
       c[i][j]=a[i][j]+b[i][j];
       cout<<"\t"<<c[i][j];
      }
     cout<<"\n\n";
    }
getch();
}
Previous
Next Post »

If you still didn't find what you're looking for, you can search this website below: