Program Menghitung Matriks Array 2 Dimensi menggunakan Borland C++
Program Menghitung Matriks Array 2 Dimensi
menggunakan Borland C++
1. Buka aplikasi Borland C++ pada PC/Laptop anda.
2. Klik File, New, Project
3. Untuk codingnya adalah sebagai berikut :
#include<iostream>
#include<conio.h>
#include<stdlib.h>
#include <dos.h>
int main(){char eko;
do{int A[10][10];
int B[10][10];
int C[10][10];
int bar,kol,kolA,kolB,kolC,pilihan;
system("color 3D");
cout<<"\t\t***********************************************"<<endl;
cout<<"\t\t* PROGRAM MENGHITUNG MATRIKS ARRAY 2 DIMENSI *"<<endl;
cout<<"\t\t* created by Fitri Febriani *"<<endl;
cout<<"\t\t***********************************************\n\n"<<endl;
cout<<"Pilih Tipe Apa Yang Ingin Anda Gunakan"<<endl;
cout<<"(1)Penjumlahan\n(2)Pengurangan\n(3)Perkalian\n"<<endl;
cout<<"Ketik Angka Program Apa Yang Akan Gunakan : ";
cin>>pilihan;if(pilihan==1){system("cls");
cout<<"\t\t******************************************"<<endl;
cout<<"\t\t* Anda Menggunakan Program Penjumlahan *"<<endl;
cout<<"\t\t******************************************\n\n"<<endl;
cout<<"Masukan Nilai Matriks A : "<<endl;
cout<<"============================"<<endl;
for(bar=1;bar<=3;bar++)
{
for(kol=1;kol<=3;kol++)
{
cout<<"A ["<<bar<<"]["<<kol<<"] = ";
cin>>A[bar][kol];
}
}
cout<<endl<<endl;
cout<<"Masukan Nilai Matriks B : "<<endl;
cout<<"============================="<<endl;
for(bar=1;bar<=3;bar++)
{
for(kol=1;kol<=3;kol++)
{
cout<<"B ["<<bar<<"]["<<kol<<"] = ";
cin>>B[bar][kol];
C[bar][kol]=(A[bar][kol]+B[bar][kol]);
}
}
system("cls");
cout<<"Hasil Perhitungan |A|+|B| : "<<endl;
cout<<"============================"<<endl;
for(bar=1;bar<=3;bar++){cout<<" | ";
for(kolA=1;kolA<=3;kolA++)
{
cout<<" "<<A[bar][kolA];
}
cout<<" | ";
cout<<" | ";
for(kolB=1;kolB<=3;kolB++)
{
cout<<" "<<B[bar][kolB];
}
cout<<" | ";
cout<<" | ";
for(kolC=1;kolC<=3;kolC++)
{
cout<<" "<<C[bar][kolC];
}
cout<<" | ";
cout<<" "<<endl;
}
}
else if(pilihan==2){system("cls");
cout<<"\t\t******************************************"<<endl;
cout<<"\t\t* Anda Menggunakan Program Pengurangan *"<<endl;
cout<<"\t\t******************************************\n\n"<<endl;
cout<<"Masukan Nilai Matriks A : "<<endl;
cout<<"============================"<<endl;
for(bar=1;bar<=3;bar++)
{
for(kol=1;kol<=3;kol++)
{
cout<<"A ["<<bar<<"]["<<kol<<"] = ";
cin>>A[bar][kol];
}
}
cout<<endl<<endl;
cout<<"Masukan Nilai Matriks B : "<<endl;
cout<<"============================="<<endl;
for(bar=1;bar<=3;bar++)
{
for(kol=1;kol<=3;kol++)
{
cout<<"B ["<<bar<<"]["<<kol<<"] = ";
cin>>B[bar][kol];
C[bar][kol]=(A[bar][kol]-B[bar][kol]);
}
}
system("cls");
cout<<"Hasil Perhitungan |A|-|B| : "<<endl;
cout<<"============================"<<endl;
for(bar=1;bar<=3;bar++){cout<<" | ";
for(kolA=1;kolA<=3;kolA++)
{
cout<<" "<<A[bar][kolA];
}
cout<<" | ";
cout<<" | ";
for(kolB=1;kolB<=3;kolB++)
{
cout<<" "<<B[bar][kolB];
}
cout<<" | ";
cout<<" | ";
for(kolC=1;kolC<=3;kolC++)
{
cout<<" "<<C[bar][kolC];
}
cout<<" | ";
cout<<" "<<endl;
}
}
else if(pilihan==3){system("cls");
cout<<"\t\t******************************************"<<endl;
cout<<"\t\t* Anda Menggunakan Program Perkalian *"<<endl;
cout<<"\t\t******************************************\n\n"<<endl;
cout<<"Masukan Nilai Matriks A : "<<endl;
cout<<"============================"<<endl;
for(bar=1;bar<=3;bar++)
{
for(kol=1;kol<=3;kol++)
{
cout<<"A ["<<bar<<"]["<<kol<<"] = ";
cin>>A[bar][kol];
}
}
cout<<endl<<endl;
cout<<"Masukan Nilai Matriks B : "<<endl;
cout<<"============================="<<endl;
for(bar=1;bar<=3;bar++)
{
for(kol=1;kol<=3;kol++)
{
cout<<"B ["<<bar<<"]["<<kol<<"] = ";
cin>>B[bar][kol];
C[bar][kol]=(A[bar][kol]*B[bar][kol]);
}
}
system("cls");
cout<<"Hasil Perhitungan |A|*|B| : "<<endl;
cout<<"============================"<<endl;
for(bar=1;bar<=3;bar++){cout<<" | ";
for(kolA=1;kolA<=3;kolA++){cout<<" "<<A[bar][kolA];
}
cout<<" | ";
cout<<" | ";
for(kolB=1;kolB<=3;kolB++)
{
cout<<" "<<B[bar][kolB];
}
cout<<" | ";
cout<<" | ";
for(kolC=1;kolC<=3;kolC++)
{
cout<<" "<<C[bar][kolC];
}
cout<<" | ";
cout<<" "<<endl;
}
}
else if(pilihan==4){system("cls");
if(pilihan>=5)cout<<"\n\n\t*******************************************************"<<endl;
cout<<"\t***Maaf Yang Anda Input Salah Silahkan Ulang Kembali***"<<endl;
cout<<"\t*******************************************************\n\n\n"<<endl;
}
cout<<"\n\nApakah Anda Ingin Mengulang? [Y/T] : ";
cin>>eko;
system("cls");
}
while(eko=='T'||eko=='T');
cout<<"Terimakasih Sudah Menggunakan Program Sederhana Ini"<<endl;
getch();
}
4. Selamat mencoba kawan.. semoga penjelasan diatas dapat bermanfaat dan mempermudah teman-teman semua dalam pembuatan program.
Tetap semangat, terus berusaha dan pantang menyerah !! Selamat belajar..
http://fitrifebriani26.blogspot.com
menggunakan Borland C++
1. Buka aplikasi Borland C++ pada PC/Laptop anda.
2. Klik File, New, Project
3. Untuk codingnya adalah sebagai berikut :
#include<iostream>
#include<conio.h>
#include<stdlib.h>
#include <dos.h>
int main(){char eko;
do{int A[10][10];
int B[10][10];
int C[10][10];
int bar,kol,kolA,kolB,kolC,pilihan;
system("color 3D");
cout<<"\t\t***********************************************"<<endl;
cout<<"\t\t* PROGRAM MENGHITUNG MATRIKS ARRAY 2 DIMENSI *"<<endl;
cout<<"\t\t* created by Fitri Febriani *"<<endl;
cout<<"\t\t***********************************************\n\n"<<endl;
cout<<"Pilih Tipe Apa Yang Ingin Anda Gunakan"<<endl;
cout<<"(1)Penjumlahan\n(2)Pengurangan\n(3)Perkalian\n"<<endl;
cout<<"Ketik Angka Program Apa Yang Akan Gunakan : ";
cin>>pilihan;if(pilihan==1){system("cls");
cout<<"\t\t******************************************"<<endl;
cout<<"\t\t* Anda Menggunakan Program Penjumlahan *"<<endl;
cout<<"\t\t******************************************\n\n"<<endl;
cout<<"Masukan Nilai Matriks A : "<<endl;
cout<<"============================"<<endl;
for(bar=1;bar<=3;bar++)
{
for(kol=1;kol<=3;kol++)
{
cout<<"A ["<<bar<<"]["<<kol<<"] = ";
cin>>A[bar][kol];
}
}
cout<<endl<<endl;
cout<<"Masukan Nilai Matriks B : "<<endl;
cout<<"============================="<<endl;
for(bar=1;bar<=3;bar++)
{
for(kol=1;kol<=3;kol++)
{
cout<<"B ["<<bar<<"]["<<kol<<"] = ";
cin>>B[bar][kol];
C[bar][kol]=(A[bar][kol]+B[bar][kol]);
}
}
system("cls");
cout<<"Hasil Perhitungan |A|+|B| : "<<endl;
cout<<"============================"<<endl;
for(bar=1;bar<=3;bar++){cout<<" | ";
for(kolA=1;kolA<=3;kolA++)
{
cout<<" "<<A[bar][kolA];
}
cout<<" | ";
cout<<" | ";
for(kolB=1;kolB<=3;kolB++)
{
cout<<" "<<B[bar][kolB];
}
cout<<" | ";
cout<<" | ";
for(kolC=1;kolC<=3;kolC++)
{
cout<<" "<<C[bar][kolC];
}
cout<<" | ";
cout<<" "<<endl;
}
}
else if(pilihan==2){system("cls");
cout<<"\t\t******************************************"<<endl;
cout<<"\t\t* Anda Menggunakan Program Pengurangan *"<<endl;
cout<<"\t\t******************************************\n\n"<<endl;
cout<<"Masukan Nilai Matriks A : "<<endl;
cout<<"============================"<<endl;
for(bar=1;bar<=3;bar++)
{
for(kol=1;kol<=3;kol++)
{
cout<<"A ["<<bar<<"]["<<kol<<"] = ";
cin>>A[bar][kol];
}
}
cout<<endl<<endl;
cout<<"Masukan Nilai Matriks B : "<<endl;
cout<<"============================="<<endl;
for(bar=1;bar<=3;bar++)
{
for(kol=1;kol<=3;kol++)
{
cout<<"B ["<<bar<<"]["<<kol<<"] = ";
cin>>B[bar][kol];
C[bar][kol]=(A[bar][kol]-B[bar][kol]);
}
}
system("cls");
cout<<"Hasil Perhitungan |A|-|B| : "<<endl;
cout<<"============================"<<endl;
for(bar=1;bar<=3;bar++){cout<<" | ";
for(kolA=1;kolA<=3;kolA++)
{
cout<<" "<<A[bar][kolA];
}
cout<<" | ";
cout<<" | ";
for(kolB=1;kolB<=3;kolB++)
{
cout<<" "<<B[bar][kolB];
}
cout<<" | ";
cout<<" | ";
for(kolC=1;kolC<=3;kolC++)
{
cout<<" "<<C[bar][kolC];
}
cout<<" | ";
cout<<" "<<endl;
}
}
else if(pilihan==3){system("cls");
cout<<"\t\t******************************************"<<endl;
cout<<"\t\t* Anda Menggunakan Program Perkalian *"<<endl;
cout<<"\t\t******************************************\n\n"<<endl;
cout<<"Masukan Nilai Matriks A : "<<endl;
cout<<"============================"<<endl;
for(bar=1;bar<=3;bar++)
{
for(kol=1;kol<=3;kol++)
{
cout<<"A ["<<bar<<"]["<<kol<<"] = ";
cin>>A[bar][kol];
}
}
cout<<endl<<endl;
cout<<"Masukan Nilai Matriks B : "<<endl;
cout<<"============================="<<endl;
for(bar=1;bar<=3;bar++)
{
for(kol=1;kol<=3;kol++)
{
cout<<"B ["<<bar<<"]["<<kol<<"] = ";
cin>>B[bar][kol];
C[bar][kol]=(A[bar][kol]*B[bar][kol]);
}
}
system("cls");
cout<<"Hasil Perhitungan |A|*|B| : "<<endl;
cout<<"============================"<<endl;
for(bar=1;bar<=3;bar++){cout<<" | ";
for(kolA=1;kolA<=3;kolA++){cout<<" "<<A[bar][kolA];
}
cout<<" | ";
cout<<" | ";
for(kolB=1;kolB<=3;kolB++)
{
cout<<" "<<B[bar][kolB];
}
cout<<" | ";
cout<<" | ";
for(kolC=1;kolC<=3;kolC++)
{
cout<<" "<<C[bar][kolC];
}
cout<<" | ";
cout<<" "<<endl;
}
}
else if(pilihan==4){system("cls");
if(pilihan>=5)cout<<"\n\n\t*******************************************************"<<endl;
cout<<"\t***Maaf Yang Anda Input Salah Silahkan Ulang Kembali***"<<endl;
cout<<"\t*******************************************************\n\n\n"<<endl;
}
cout<<"\n\nApakah Anda Ingin Mengulang? [Y/T] : ";
cin>>eko;
system("cls");
}
while(eko=='T'||eko=='T');
cout<<"Terimakasih Sudah Menggunakan Program Sederhana Ini"<<endl;
getch();
}
4. Selamat mencoba kawan.. semoga penjelasan diatas dapat bermanfaat dan mempermudah teman-teman semua dalam pembuatan program.
Tetap semangat, terus berusaha dan pantang menyerah !! Selamat belajar..
http://fitrifebriani26.blogspot.com
Komentar
Posting Komentar