forked from kokonior/CSS-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram Kalkulator Sederhana C++
More file actions
52 lines (45 loc) · 1001 Bytes
/
Program Kalkulator Sederhana C++
File metadata and controls
52 lines (45 loc) · 1001 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <conio.h>
#include <iostream>
#include <string>
using namespace std;
int main(){
int bil1,bil2, pil;
float hasil;
string operasi;
cout<<"PILIH OPERATOR ARITMATIKA"<<endl;
cout<<"1. Penjumlahan"<<endl;
cout<<"2. Pengurangan"<<endl;
cout<<"3. Perkalian"<<endl;
cout<<"4. Pembagian"<<endl;
cout<<"5. Modulus"<<endl;
cout<<endl;
cout<<"Masukan Pilihan : ";
cin>>pil;
cout<<"Masukan Bilangan pertama : ";
cin>>bil1;
cout<<"Masukan Bilangan kedua : ";
cin>>bil2;
switch(pil){
case 1 : hasil=bil1+bil2;
operasi='+';
break;
case 2 : hasil=bil1-bil2;
operasi='-';
break;
case 3 : hasil=bil1*bil2;
operasi='*';
break;
case 4 : hasil=bil1/bil2;
operasi='/';
break;
case 5 : hasil=bil1%bil2;
operasi='%';
break;
default :
cout<<"Salah Masukan Operator"<<endl;
}
cout<<"-----------------------------"<<endl;
cout<<" "<<bil1<<operasi<<bil2<<"="<<hasil<<endl;
cout<<"-----------------------------"<<endl;
getch();
}