Calculating Matrix Determinant berordo 2 × 2

In Algebra we can know about the matrix. In the matrix we can calculate the value of its determinant.

algoritma :

Algoritma menghitung determinan matriks berordo 2×2
{membaca bilangan dalam matrik berordo 2×2 (a,b,c,d) kemudian menghitung determinan matriks determinan=a*b-c*d, lalu outputnya berupa hasil determinan dari matriks berordo 2×2 }

Deklarasi
a,b,c,d : integer {input }
hasildeterminan : integer {output }

Deskripsi
read a,b,c,d (isi matrik)
determinan=a*b-c*d
write hasildeterminan

program C++
#include
#include
class matriks {
public:
void isimatriks();
void determinan();
private:
int A[2][2];
int hasildeterminan;
};
void matriks::isimatriks(){
cout << "PROGRAM MENCARI DETERMINAN SUATU MATRIKS BERORODO 2X2"<<endl;
for(int i=0;i<2;i++){
cout << "baris" << i << ":";
for(int j=0;j> A[i][j];
}
}
void matriks::determinan(){
hasildeterminan=A[0][0]*A[1][1]-A[0][1]*A[1][0];
cout<<"a= "<<A[0][0]<<endl;
cout<<"b= "<<A[0][1]<<endl;
cout<<"c= "<<A[1][0]<<endl;
cout<<"d= "<<A[1][1]<<endl;
cout<<"determinan= "<<"a*d-b*c";
cout<<A[0][0]<<"x"<<A[1][1]<<"-"<<A[0][1]<<"x"<<A[1][0]<<endl;
cout << "hasil determinan = " << hasildeterminan << endl;
}
int main(){
matriks x;
x.isimatriks();
x.determinan();

getch();
return 0;
}
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: