Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save inact25/b8ebc94310ae7865d1c72cff0258ca3d to your computer and use it in GitHub Desktop.
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…
#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<<" ";
}
@GF-Elite
Copy link

GF-Elite commented Mar 2, 2023

izin comot min boleh kan

@Bayupppp
Copy link

Kok gak bisa disalin si

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment