Wednesday, 30 January 2013

How to calculate 2x2 Matrix in Cplusplus.

In this program we  discuss 2x2 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<iostream>
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;
}

Output:




Subscribe to get the latest right to your inbox:

0 comments:

Post a Comment

Some HTML Code