C++ Calculator
#include <iostream>
using namespace std;
int main()
{
int nilai1, nilai2, hasil;
string operasi;
cout <<"CALCULATOR"<< endl;
cout << "Masukkan Nilai Pertama" << endl;
cin >> nilai1;
cout << "Masukkan Nilai Kedua" << endl;
cin >> nilai2;
cout <<"Masukkan Pilihan Operasi (+, -, *, /, %)" << endl;
cin>> operasi;
if(operasi=="+")
{
hasil=nilai1+nilai2;
cout <<"Hasil= " << hasil << endl;
}
else if(operasi=="-")
{
hasil=nilai1-nilai2;
cout <<"Hasil= " << hasil << endl;
}
else if(operasi=="*")
{
hasil=nilai1*nilai2;
cout <<"Hasil= " << hasil <<endl;
}
else if(operasi=="/")
{
hasil=nilai1/nilai2;
cout <<"Hasil= " << hasil << endl;
}
else if(operasi=="%")
{
hasil=nilai1%nilai2;
cout <<"Hasil= " << hasil << endl;
}
else
{
cout << "Maaf Tidak Tersedia" << endl;
}
return 0;
}
Hasilnya seperti ini :