Posted by : Glen Sajori Kamis, 28 Februari 2013

Isi coding program sebagai berikut :

#include <cstdlib>
#include <iostream>

using namespace std;

double hasilp,hasilpp,hasils,hasill;
void persegi(double x)
{
 hasilp=x*x;
}
void persegipanjang(double p,double l)
{
 hasilpp=p*l;
}
void segitiga(double s,double t)
{
 hasils=0.5*s*t;
}
void lingkaran(double j)
{
 hasill=3.14*j*j;
}
int main(int argc, char *argv[])
{
    double a,b,c,d,e,f;
    int pilih;
    char anda;
    do
    {
     cout<<" pilih 1.PERSEGI, 2.PERSEGI PANJANG, 3. SEGITIGA, 4. LINGKARAN=";
     cin>>pilih;
     if (pilih==1)
     {
      cout<<" sisi=";
      cin>>a;
      persegi(a);
      cout<<"LUAS= "<<hasilp<<endl;
     }
     else if(pilih==2)
     {
      cout<<"panjang =";
      cin>>b;
      cout<<"lebar =";
      cin>>c;
      persegipanjang(b,c);
      cout<<"LUAS= "<<hasilpp<<endl;
     }
     else if(pilih==3)
     {
      cout<<"alas =";
      cin>>d;
      cout<<"tinggi =";
      cin>>e;
      segitiga(d,e);
      cout<<"LUAS= "<<hasils<<endl;
     }
     else if(pilih==4)
     {
      cout<<"jari-jari=";
      cin>>f;
      lingkaran(f);
      cout<<"LUAS= "<<hasill<<endl;
     }
     else
      {
      cout<<" error"<<endl;
     }
     cout<<"APAKAH ANDA INGIN MENGULANG?(Y/T) ";
     cin>>anda;
 }
 while(anda=='y'||anda=='Y');
 system("PAUSE");
 return EXIT_SUCCESS;
}
 
Kalau di RUN akan menjadi seperti ini :




 

Selamat Mencoba...

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Translate to Your Language

STMIK AMIKOM YOGYAKARTA

Followers

✠Ulquίoґґ∆✠. Diberdayakan oleh Blogger.

Copyright © Free Download+§hare Anything That You Want -Black Rock Shooter- Powered by Blogger - Designed by Johanes Djogan