Archive for 2013-12-29

C++ Program That Perform Number Operation(Malay)



#include <iostream>
using namespace std;

void pilihansaya();
double add(double, double);
double subtract(double, double);
double multiply(double, double);
double divide(double, double);

int main()
{
double x, y;
int pilihan;
do
{
pilihansaya();
cin >> pilihan;
switch (pilihan)
{
case 1:
cout << "Masukkan Dua Nombor: ";
cin >> x >> y;
cout << "Jumlahnya adalah:" << add(x,y) <<endl;
break;
case 2:
cout << "Masukkan Dua Nombor: ";
cin >> x >> y;
cout << "Perbezaannya adalah: " << subtract(x,y) <<endl;
break;
case 3:
cout << "Masukkan Dua Nombor: ";
cin >> x >> y;
cout << "Jumlahnya adalah: " << multiply(x,y) <<endl;
break;
case 4:
cout << "Masukkan Dua Nombor: ";
cin >> x >> y;
cout << "Pembahagiannya adalah: " << divide(x,y) <<endl;
break;
default:
cout << "Jangan Main Main" << endl;
}
}while (pilihan != 5);

return 0;
}

void pilihansaya()
{
cout << "++++++++++" << endl;
cout<<"Pilihan Menu:"<<endl;
cout << "1: Tambah " << endl;
cout << "2: Tolak" << endl;
cout << "3: Darab " << endl;
cout << "4: Bahagi " << endl;
cout << "++++++++++ " << endl;
cout << "Pilihan Anda :";
}

double add(double a, double b)
{
return a+b;
}

double subtract(double a, double b)
{
return a-b;
}

double multiply(double a, double b)
{
return a*b;
}

double divide(double a, double b)
{
return a/b;
}

Posted by Unknown

© Information Technology