Program Perkalian Matrik dengan Visual C++ 2005


Programnya :
#include <iostream>

using namespace std;

int main()

{

//Deklarasi variabel

int m[2][3],n[3][2],mn[2][2]; // matrik m[2 baris][3 kolom],n[3 baris][2 kolom]

int jumlah; //Jumlah

//Nilai matrik m

m[0][0]=2;

m[0][1]=4;

m[0][2]=6;

m[1][0]=3;

m[1][1]=9;

m[1][2]=5;

//Nilai matrik n

n[0][0]=7;

n[0][1]=1;

n[1][0]=-2;

n[1][1]=9;

n[2][0]=4;

n[2][1]=3;

for(int i=0;i<2;i++)

{

for(int j=0;j<2;j++)

{

jumlah=0;

for(int l=0;l<3;l++)

{

jumlah+=(m[i][l]*n[l][j]); //Penjumlahan dan Perkalian

}

mn[i][j]=jumlah;

cout<<mn[i][j]<<” “;

}

cout<<endl;

}

return 0;

}

 

Hasilnya :

perkalian

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