#include <iostream.h>
#include <conio.h>
void main()
{
awal:
float a, b;
char c;
cout << "\n\t--------------Kalkulator--------------\n";
cout << "\n";
cout << "\n";
cout << "\n\tPilihan operator:\n";
cout << "\t[+] Penjumlahan\n";
cout << "\t[-] Pengurangan\n";
cout << "\t[*] Perkalian\n";
cout << "\t[/] Pembagian\n";
cout << "\t[=] Hasilnya\n";
cout << "\n\tMasukkan Perhitungan\t: ";
cin >> a;
cout << " ";
cin >> c;
do
{
cout << " ";
cin >> b;
switch (c)
{
case '*':
a=a*b;
break;
case '/':
a=a/b;
break;
case '+':
a=a+b;
break;
case '-':
a=a-b;
break;
case '=':
break;
default:
goto awal;
}
cout << " ";
cin >> c;
}
while (c!='=');
cout << "\n\tHasilnya adalah\t\t: " << a;
getche ();
}
#include <conio.h>
void main()
{
awal:
float a, b;
char c;
cout << "\n\t--------------Kalkulator--------------\n";
cout << "\n";
cout << "\n";
cout << "\n\tPilihan operator:\n";
cout << "\t[+] Penjumlahan\n";
cout << "\t[-] Pengurangan\n";
cout << "\t[*] Perkalian\n";
cout << "\t[/] Pembagian\n";
cout << "\t[=] Hasilnya\n";
cout << "\n\tMasukkan Perhitungan\t: ";
cin >> a;
cout << " ";
cin >> c;
do
{
cout << " ";
cin >> b;
switch (c)
{
case '*':
a=a*b;
break;
case '/':
a=a/b;
break;
case '+':
a=a+b;
break;
case '-':
a=a-b;
break;
case '=':
break;
default:
goto awal;
}
cout << " ";
cin >> c;
}
while (c!='=');
cout << "\n\tHasilnya adalah\t\t: " << a;
getche ();
}
0 komentar:
Posting Komentar