Posted by : Unknown
Selasa, 26 November 2013
#include<constrea.h>
#include<cstring>
main()
{
int
x,y,hasil;
cout<<"KALKULATOR SEDERHANA"<<endl<<endl;
cout<<"daftar operator aritmatika :"<<endl;
string jumlah
="(1) penjumlahan";
cout<<jumlah<<endl;
string
pengurangan="(2) pengurangan";
cout<<pengurangan<<endl;
string
pembagian="(3) pembagian";
cout<<pembagian<<endl;
string
perkalian="(4) perkalian";
cout<<perkalian<<endl<<endl;
cout<<"masukan nilai 1 = ";
cin>>x;
cout<<"masukan nilai 2 = ";
cin>>y;
a:
int z;
cout<<"masukan nomer operator
aritmatika = ";
cin>>z;
if(z==1)
{
hasil = x+y;
cout<<"hasil
operasi"<<jumlah<<", "<<x<<" dan
"<<y<<" = "<<hasil<<endl;
}
else if(z==2)
{
hasil = x-y;
cout<<"hasil operasi"<<pengurangan<<",
"<<x<<" dan "<<y<<" =
"<<hasil<<endl;
}
else if(z==3)
{
hasil = x/y;
cout<<"hasil operasi"<<pembagian<<",
"<<x<<" dan "<<y<<" =
"<<hasil<<endl;
}
else if(z==4)
{
hasil = x*y;
cout<<"hasil operasi"<<perkalian<<",
"<<x<<" dan "<<y<<" =
"<<hasil<<endl;
}
else
{
cout<<"nomer operator
aritmatika salah"<<endl<<endl;
goto
a;
}
getch();
}
Sumber : http://budiit.blogspot.com