How to calculate 2×2 Matrix in Cplusplus.

By | January 30, 2013
2x2-matrixQuestion: In this program we  discuss 2×2 Matrix in Cplusplus. In the matrix multiplication AB, the number of columns in matrix A must be equal to the number of rows in matrix B. The resulting product matrix will have the same number of rows as matrix A and the same number of columns as B.

Source Code

#include

using namespace std;

int main()
{
             int a[2][2];
             cout<<”Enter Number\n”;
            for(int row=0;row<2;row++)
            {
                        for(int col=0;col<2;col++)
                        {
                                    cin>>a[row][col];
                        }
            cout<<endl;
            }
            cout<<”determinant:”;
                        cout<<a[0][0]*a[1][1]-a[0][1]*a[1][0]<<endl;
                        return 0;
}

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS