TUGAS AKHIR

PERTEMUAN II ARRAY

#include<iostream>
#include<conio.h>
#include<iomanip>
using namespace std;
int i,j,baris,kolom,m1[10][10],m2[10][10],hasil[10][10];
main()
{
do
{
cout<<“Jumlah Baris = “;cin>>baris;
cout<<“Jumlah Kolom = “;cin>>kolom;
}
while
((baris>10)||(kolom>10));
cout<<“\nMatriks A”<<endl;
for(i=0;i<baris;i++)
for(j=0;j<kolom;j++)
{
cout<<“data[“<<i<<“,”<<j<<“]=”;cin>>m1[i][j];
}

for(i=0;i<baris;i++)
{
cout<<‘\n’;for(j=0;j<kolom;j++)cout<<setw(4)<<m1[i][j];
}
cout<<” “<<endl;
cout<<“\nMatriks B”<<endl;
for(i=0;i<baris;i++)
for(j=0;j<kolom;j++)
{
cout<<“data[“<<i<<“,”<<j<<“]=”;cin>>m2[i][j];
}

for(i=0;i<baris;i++)
{
cout<<‘\n’;for(j=0;j<kolom;j++)cout<<setw(4)<<m2[i][j];
}
cout<<” “<<endl;
for(i=0;i<baris;i++)
for(j=0;j<kolom;j++)
hasil[i][j] = m1[i][j] + m2[i][j];
cout<<“\nHasil:”<<endl;
cout<<“Matriks A + Matriks B = Matriks C”;
for(i=0;i<baris;i++)
{
cout<<‘\n’;for(j=0;j<kolom;j++)cout<<setw(4)<<m1[i][j];
cout<<” “;for(j=0;j<kolom;j++)cout<<setw(4)<<m2[i][j];
cout<<” “;for(j=0;j<kolom;j++)cout<<setw(4)<<hasil[i][j];
cout<<endl;
}
cout<<” “<<endl;
cout<<“Thanks For Trying”<<endl;
cout<<“Minal Aidin Wal Faidzin, by Rahman”<<endl;
getch();
}

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s