using namespace std;
//Hasan Ma'ruf | hasanxch@gmail.com | TIF15 | UIN-SUKA
//Tugas pemrograman | semester 1
int main(){
int a, b, c, d, e, f, g, h, i;
int operasi, hasil;
string pesan1, pesan2;
pesan1="Masukkan nilai pertama : ";
pesan2="Masukkan nilai kedua : ";
cout << "1 = Penjumlahan\n";
cout << "2 = Pengurangan\n";
cout << "3 = Perkalian\n";
cout << "4 = Pembagian\n";
cout << "__________________________\n";
cout << "Masukan kode operasi = ";
cin >> operasi;
if (operasi==1){
cout << pesan1;
cin >> a;
cout << pesan2;
cin >> b;
hasil = a + b;
}
if (operasi==2){
cout << pesan1;
cin >> c;
cout << pesan2;
cin >> d;
hasil = c - d;
}
if (operasi==3){
cout << pesan1;
cin >> e;
cout << pesan2;
cin >> f;
hasil = e * f;
}
if (operasi==4){
cout << pesan1;
cin >> g;
cout << pesan2;
cin >> h;
hasil = c / d;
}
cout << "__________________________\n";
cout << "Hasilnya adalah "<<hasil<<endl;
return 0;
system ("pause");
}
Post a Comment