Ini Source codenya
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
int A[2][2],B[2][2],C[2][2];
void inputmatriksA()
{
cout<<"Matriks A"<<endl;
for (int i=0;i<2;i++)
for (int j=0;j<2;j++)
{
cout<<"Elemen ["<<(i+1)<<","<<(j+i)<<"]:";
cin>>A[i][j];
}
}
void inputmatriksB()
{
cout<<"Matriks B"<<endl;
for (int i=0;i<2;i++)
for (int j=0;j<2;j++)
{
cout<<"Elemen B ["<<(i+1)<<","<<(j+i)<<"]:";
cin>>B[i][j];
}
}
void tampilA()
{
cout<<"Matriks A"<<endl;
for (int i=0;i<2;i++)
{
for (int j=0;j<2;j++)
cout<<setw(2)<<A[i][j]<<" ";
cout<<endl;
}
}
void tampilB()
{
cout<<"Matriks B"<<endl;
for (int i=0;i<2;i++)
{
for (int j=0;j<2;j++)
cout<<setw(2)<<B[i][j]<<" ";
cout<<endl;
}
}
void tampilC()
{
cout<<"Matriks C"<<endl;
for (int i=0;i<2;i++)
{
for (int j=0;j<2;j++)
cout<<setw(2)<<C[i][j]<<" ";
cout<<endl;
}
}
void Jumlah()
{
for (int i=0;i<2;i++)
{
for (int j=0;j<2;j++)
C[i][j]=A[i][j]+B[i][j];
cout<<endl;
}
}
void main()
{
clrscr();
inputmatriksA();
inputmatriksB();
cout<<endl;
tampilA();
tampilB();
Jumlah();
tampilC();
getch();
}
Tidak ada komentar:
Posting Komentar