Subscribe:

Jumat, 19 April 2013

Program Kalkulator C++


#include
#include
#include

using namespace std;

int main(int argc, char *argv[])
{
    {
             cout <<"Selamat Datang\n";
    cout <<"Program ini adalah program kalkulator sederhana\n";
    cout <<"Pilih sesuai selera anda\n\n";
}
  int p;
  double a1,a2,h;
  cout<<"1.penjumlahan\n";
  cout<<"2.pengurangan\n";
  cout<<"3.pembagian\n";
  cout<<"4.perkalian\n";
  cout<<"5.perpangkatan\n";
  cout<<"6.perakaran\n\n";
  cin>>p;

 switch (p)
 {
 case 1:
  cout<<"masukkan nilai a1 = ";
  cin>>a1;
  cout<<"masukkan nilai a2 = ";
  cin>>a2;
  h=a1+a2;
  cout<<"hasil penjumlahan = "<
  break;

  case 2:
  cout<<"masukkan nilai a1 = ";
  cin>>a1;
  cout<<"masukkan nilai a2 = ";
  cin>>a2;
  h=a1-a2;
  cout<<"hasil pengurangan = "<
break;

  case 3:
  cout<<"masukkan nilai a1 = ";
  cin>>a1;
  cout<<"masukkan nilai a2 = ";
  cin>>a2;
  h=a1/a2;
  cout<<"hasil pembagian = "<
break;

  case 4:
  cout<<"masukkan nilai a1 = ";
  cin>>a1;
  cout<<"masukkan nilai a2 = ";
  cin>>a2;
  h=a1*a2;
  cout<<"hasil perkalian = "<
break;

  case 5:
  cout<<"masukkan nilai a1 = ";
  cin>>a1;
  cout<<"masukkan nilai a2 = ";
  cin>>a2;
  h=pow(a1,a2);
  cout<<"hasil perpangkatan = "<
break;

  case 6:
  cout<<"masukkan nilai a1 = ";
  cin>>a1;
  h=sqrt(a1);
  cout<<"hasil perakaran = "<
break;

   }
    system("PAUSE");
    return EXIT_SUCCESS;
}


0 komentar: