matrik ordo 3X3

#include <iostream.h>
#include <conio.h>

typedef int matriks[20][20];
void main()

{
int clm_a=3,clm_b=3,row_a=3,row_b=3,i,j;
matriks A,B,C;
clrscr();

while ((clm_a!=clm_b) || (row_a!=row_b));

clrscr();
cout<<“PROGRAM PENJUMLAHAN MATRIK ORDO 3X3 “<<endl;
cout<<“Inputkan Angka Matriks A : “<<endl;
for(i=1;i<=row_a;i++)
{
for(j=1;j<=clm_a;j++)
{
cout<<“A[“<<i<<“,”<<j<<“] = “;
cin>>A[i][j];
}
}

clrscr();
cout<<“Masukkan Nilai Matriks B : “<<endl;
for(i=1;i<=row_b;i++)
{
for(j=1;j<=clm_b;j++)
{
cout<<“B[“<<i<<“,”<<j<<“] = “;
cin>>B[i][j];
}
}

clrscr();
cout<<endl;
//Proses Penjumlahan Matriks
for(i=1;i<=row_a;i++)
{
for(j=1;j<=clm_a;j++)
{
C[i][j] = A[i][j] + B[i][j];
}
}

clrscr();
//Output Matriks A
gotoxy(1,5);
cout<<“A = “;
for(i=1;i<=row_a;i++)
{
for(j=1;j<=clm_a;j++)
{
gotoxy(2+3*j,2+2*i);
cout<<A[i][j];
}
}

//Output Matriks B
gotoxy(1,13);
cout<<“B = “;
for(i=1;i<=row_b;i++)
{
for(j=1;j<=clm_b;j++)
{
gotoxy(2+4*j,10+2*i);
cout<<B[i][j];
}
}

//Output Matriks C
gotoxy(1,20);
cout<<“C = “;
for(i=1;i<=row_a;i++)
{
for(j=1;j<=clm_a;j++)
{
gotoxy(3+4*j,17+2*i);
cout<<A[i][j];
}
}

gotoxy(17,20);
cout<<” + “;
for(i=1;i<=row_b;i++)
{
for(j=1;j<=clm_b;j++)
{
gotoxy(18+4*j,17+2*i);
cout<<B[i][j];
}
}

gotoxy(32,20);
cout<<” = “;
for(i=1;i<=row_a;i++)
{
for(j=1;j<=clm_a;j++)
{
gotoxy(33+4*j,17+2*i);
cout<<C[i][j];
}
}

getch();

}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s