Created
August 7, 2016 17:11
-
-
Save inact25/b8ebc94310ae7865d1c72cff0258ca3d to your computer and use it in GitHub Desktop.
KODING123 - Tutorial Membuat Program Kalkulator Algoritma Bahasa Pemrograman C++ Hari ini kita akan membahas tentang "Bagaimana Cara Membuat Program Kalkulator Sederhana Menggunakan bahasa Pemrograman C++. Dalam pembuatan program kalkulator sederhana ini kita akan menggunakan bahasa pemrograman C++. Bagaimana cara membuat nya ? Perhatikan Langka…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
int tambah (float a, float b){ | |
return ( a + b ); | |
} | |
int kurang (float a, float b ){ | |
return ( a - b ); | |
} | |
int kali (float a, float b ){ | |
return ( a * b ); | |
} | |
int bagi (float a, float b ){ | |
return (a / b ); | |
} | |
int main (){ | |
int bil1, bil2; | |
char pilihan; | |
cout<<" ========================================"<<endl; | |
cout<<" | Program Kalkulator Sederhana |"<<endl; | |
cout<<" ========================================"<<endl; | |
cout<<endl; | |
cout<<" ========================================"<<endl; | |
cout<<" | Masukan Pilihan |"<<endl; | |
cout<<" ========================================"<<endl; | |
cout<<" | |"<<endl; | |
cout<<" | (A) Tambah (B) Kurang |"<<endl; | |
cout<<" | (C) Kali (D) Bagi |"<<endl; | |
cout<<" | |"<<endl; | |
cout<<" ========================================"<<endl; | |
cout<<" Masukan Pilihan : ";cin>>pilihan; | |
cout<<endl; | |
if ( pilihan == 'A' || pilihan == 'a' ) { | |
cout<<" ========================================"<<endl; | |
cout<<" | Masukan Bilangan |"<<endl; | |
cout<<" ========================================"<<endl; | |
cout<<" | |"<<endl; | |
cout<<" | Masukan Bilangan pertama : ";cin>>bil1; | |
cout<<" | Masukan Bilangan kedua : ";cin>>bil2; | |
cout<<" | |"<<endl; | |
cout<<" ========================================"<<endl; | |
cout<<" | Hasilnya Adalah : "<<tambah(bil1,bil2)<<" |"<<endl; | |
cout<<" ========================================"<<endl; | |
} | |
else if ( pilihan == 'B' || pilihan == 'b' ) { | |
cout<<" ========================================"<<endl; | |
cout<<" | Masukan Bilangan |"<<endl; | |
cout<<" ========================================"<<endl; | |
cout<<" | |"<<endl; | |
cout<<" | Masukan Bilangan pertama : ";cin>>bil1; | |
cout<<" | Masukan Bilangan kedua : ";cin>>bil2; | |
cout<<" | |"<<endl; | |
cout<<" ========================================"<<endl; | |
cout<<" | Hasilnya Adalah : "<<kurang(bil1,bil2)<<" |"<<endl; | |
cout<<" ========================================"<<endl; | |
} | |
else if ( pilihan == 'c' || pilihan == 'C' ) { | |
cout<<" ========================================"<<endl; | |
cout<<" | Masukan Bilangan |"<<endl; | |
cout<<" ========================================"<<endl; | |
cout<<" | |"<<endl; | |
cout<<" | Masukan Bilangan pertama : ";cin>>bil1; | |
cout<<" | Masukan Bilangan kedua : ";cin>>bil2; | |
cout<<" | |"<<endl; | |
cout<<" ========================================"<<endl; | |
cout<<" | Hasilnya Adalah : "<<kali(bil1,bil2)<<" |"<<endl; | |
cout<<" ========================================"<<endl; | |
} | |
else if ( pilihan == 'D' || pilihan == 'd' ) { | |
cout<<" ========================================"<<endl; | |
cout<<" | Masukan Bilangan |"<<endl; | |
cout<<" ========================================"<<endl; | |
cout<<" | |"<<endl; | |
cout<<" | Masukan Bilangan pertama : ";cin>>bil1; | |
cout<<" | Masukan Bilangan kedua : ";cin>>bil2; | |
cout<<" | |"<<endl; | |
cout<<" ========================================"<<endl; | |
cout<<" | Hasilnya Adalah : "<<bagi(bil1,bil2)<<" |"<<endl; | |
cout<<" ========================================"<<endl; | |
} | |
cout<<endl; | |
cout<<" ========================================"<<endl; | |
cout<<" | Learn more @ koding123.com |"<<endl; | |
cout<<" ========================================"<<endl; | |
cout<<" "; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
izin comot min boleh kan