-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1625 from hioan-dev/oans_nb
contributed simplecalculator c++
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
Program's_Contributed_By_Contributors/C++/SimpleCalculator.cpp
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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(); | ||
} |