WAP TO DETERMINE WHETHER A MATRIX IS EQUAL OR NOT

 

#include<iostream.h>
#include<conio.h>
Void main()
{
      int a[3][3],b[3][3],i,j,flag=0;
      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 elements 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++)
                {
                     if(a[i][j]!=b[i][j])
                     {
                           flag=1;
                           break;
                      }
                }
        }
        if(flag==0)
        cout<<”Matrix are equal”;
        else
           cout<<”Matrix are not equal”;
         getch();
}

       

Comments

Popular Posts