Contoh Program Sederhana Borland C++ - Penghitung Operasi Aritmatika , Pengurangan Dan Pertambahan , Relasi , Dan Logika

Contoh Program Penghitung Operasi Pada Borland C++
Contoh Program Penghitung Operasi Pada Borland C++

#include <stdio.h>
#include <conio.h>
#include <iostream.h>
int pilihan;





void aritmatika()

{

int x,y,a,b,c,d;

cout<<endl;

cout<<" ====================================================== "<<endl;

cout<<" Fungsi Menghitung Aritmatika"<<endl<<"Masukan Nilai A :";

cin>>x;

cout<<" Masukan Nilai B :";

cin>>y;

a=x+y;

b=x-y;

c=x%y;

d=x*y;

cout<<endl;

cout<<" A = X + Y Adalah :"<<a;

cout<<" A = X - Y Adalah :"<<b;

cout<<" A = X % Y Adalah :"<<c;

cout<<" A = X * Y Adalah :"<<d;

getche();



}



void prefix()

{

int a=16,b=8;



cout<<" ====================================================== "<<endl;

cout<<" Fungsi Menghitung Prefix"<<endl;

cout<<" Nilai A = %d"<<a;

cout<<" Nilai ++A = %d"<<++a;

cout<<" Nilai B = %d"<<b;

cout<<" Nilai --B = %d"<<--b;



getche();

}



void relasi()

{

float a,b,c,d,e,f,x,y;

cout<<" ====================================================== "<<endl;

cout<<" Fungsi Menghitung Relasi"<<endl<<"Masukan Nilai X :";

cin>>x;

cout<<"Masukan Nilai Y :";

cin>>y;

a = x == y;

b = x != y ;

c = x > y;

d = x < y;

e = x >= y;

f = x <= y;



cout<<endl;

cout<<"Hasil dari " <<x<< " == " <<y<< " = "<<a<<endl;

cout<<"Hasil dari " <<x<< " != " <<y<< " = "<<b<<endl;

cout<<"Hasil dari " <<x<< " > " <<y<< " = "<<c<<endl;

cout<<"Hasil dari " <<x<< " < " <<y<< " = "<<d<<endl;

cout<<"Hasil dari " <<x<< " >= " <<y<< " = "<<e<<endl;

cout<<"Hasil dari " <<x<< " <= " <<y<< " = "<<f<<endl;



getche();

}



void logika()

{

int a,b,c;

cout<<" ====================================================== "<<endl;

cout<<" Fungsi Menghitung Logika"<<endl<<"Masukan Nilai A :";

cin>>a;

b = (a + 8 < 12);

c = !(b);





cout<<endl;

cout<<"Nilai A = " <<a<<endl;

cout<<"Nilai B = (a + 8 < 12) = " <<b<<endl;

cout<<"Nilai C = !(b) = " <<c<<endl;





getche();

}







main()

{

Programku:

clrscr();

cout<<" ===========[ APLIKASI PENGHITUNG OPERASI ]============ "<<endl;

cout<<" ============= Copyright - Ronny Liem ============= "<<endl;

cout<<" ====================================================== "<<endl;

cout<<" |-| Pilih Salah Satu Fungsi Yang Ingin Kamu Gunakan|-|"<<endl

<<" |1|.Menghitung Operasi Aritmatika |*|"<<endl

<<" |2|.Menghitung Operasi Penambahan & Pengurangan |*|"<<endl

<<" |3|.Menghitung Operasi Relasi |*|"<<endl

<<" |4|.Menghitung Operasi Logika |*|"<<endl

<<" ================= SELAIN DIATAS KELUAR ==============="<<endl;



cout<<"Silakan Masukan Pilihan Anda[0-3]:";cin>>pilihan;



if(pilihan==0)

{

goto keluar;

}

else if(pilihan==1)

{



aritmatika();

goto Programku;

}

else if(pilihan==2)

{

prefix();

goto Programku;

}

else if(pilihan==3)

{

relasi();

goto Programku;

}

else if(pilihan==4)

{

logika();

goto Programku;

}







keluar:

cout<<endl<<endl<<endl;

cout<<" ====================================================== "<<endl;

cout<<" || THANKS YOU FOR USING MY PROGRAM || "<<endl;

cout<<" ====================================================== "<<endl;

getche();

}

Subscribe Untuk Mendapatkan Info Terbaru Dari Kami Lewat Email: