WAP TO ADD TWO MATRICES


#include<iostream.h>
#include<conio.h>
Void main()
{
     int a[3][3],b[3][3],c[3][3],i,j;
     clrscr();
     cout<<”Enter the first matrix elements:”;
     for(i=0;i<3;i++)
     {
           for(j=0;j<3;j++)
           {
                 cin>>a[i][j];
           }
     }
     cout<<”First matrix elemets are:”;
     for(i=0;i<3;i++)
     {
          for(j=0;j<3;j++)
          {
                   cout<<a[i][j];
                   cout<<”\t”;
          }
           cout<<”\n”;
    }
    cout<<”Enter the second matrix elements:”;
    for(i=0;i<3;i++)
    {
           for(j=0;j<3;j++)
           {
                  cin>>b[i][j];
           }
    }
    cout<<”Second matrix elements are:”;
    for(i=0;i<3;i++)
    {
          for(j=0;j<3;j++)
          {
                cout<<b[i][j];
                cout<<”\t”;
          }
            cout<<”\n”;
     }
     for(i=0;i<3;i++)
     {
            for(j=0;j<3;j++)
            {
                   C[i][j]=a[i][j]+b[i][j];
            }
     }
     cout<<”Output matrix is:”;
     for(i=0;i<3;i++)
     {
            for(j=0;j<3;j++)
            {
                   cout<<c[i][j];
                   cout<<”\t”;
            }
              cout<<”\n”;
     }
      getch();
}


         


Comments

Popular Posts