#include <iostream.h> #include <conio.h> main(){ int bil1,bil2,pil; float hsl; cout<<"Kalkulator Sederhana\n"; cout<<"Pilih salah satu :\n"; cout<<"[1] Operasi Penjumlahan\n"; cout<<"[2] Operasi Pengurangan\n"; cout<<"[3] Operasi Pembagian\n"; cout<<"[4] Operasi Perkalian\n"; cout<<"Masukkan pilihan anda : "; cin>>pil; switch (pil) { case 1: cout<<"bil 1 = "; cin>>bil1; cout<<"bil 2 = "; cin>>bil2; hsl=bil1+bil2; cout<<"Hasil = "<<hsl<<endl<<endl; break; case 2: cout<<"bil 1 = "; cin>>bil1; cout<<"bil 2 = "; cin>>bil2; hsl=bil1-bil2; cout<<"Hasil = "<<hsl<<endl<<endl; break; case 3: cout<<"bil 1 = "; cin>>bil1; cout<<"bil 2 = "; cin>>bil2; hsl=bil1/bil2; cout<<"Hasil = "<<hsl<<endl<<endl break; case 4: cout<<"bil 1 = " cin>>bil1; cout<<"bil 2 = "; cin>>bil2; hsl=bil1*bil2; cout<<"Hasil = "<<hsl<<endl<<endl; break; } getch(); }
Setelah di compile and run :