Program Penghitung Luas dan Keliling Lingkaran

     Sekedar mengingatkan kembali rumus untuk menghitung luas lingkaran adalah:

    Luas = phi * r * r

    sedangkan untuk keliliing:

    Keliling = phi * d
    atau
    Keliling = phi * r * 2





    Nah berikut adalah kode program untuk menghitung Luas dan Keliling lingkaran

    Untuk Program yang statis (tidak ada proses input, nilai jari-jari ditentukan di dalam kode program) :


    #include <iostream>
    #include <conio>
    #define phi 3.14

    main()
    {
    float r=15;
            float luas=phi*r*r;
            float keliling=phi*r*2;

    cout<<"Program volume dan luas Lingkaran\n";
    cout<<"\nJari-jari\t= "<<r;
    cout<<"\n--------------------------";
    cout<<"\nLuas\t\t= "<<luas;
    cout<<"\nKeliling\t= "<<keliling;

      getch();
    }


    Untuk Program yang dinamis (ada proses input, nilai jari-jari bisa ditentukan saat pross input) :


    #include <iostream>
    #include <conio>
    #define phi 3.14

    main()
    {
    float r;

    cout<<"Program volume dan luas Lingkaran\n";
    cout<<"\nMasukan Jari-jari = ";
            cin>>r;
            float luas=phi*r*r;
            float keliling=phi*r*2;
    cout<<"\n--------------------------";
    cout<<"\nLuas\t\t= "<<luas;
    cout<<"\nKeliling\t= "<<keliling;
      getch();
    }

    atau anda bisa mendownload program sekaligus sourcenya pada link di bawah ini:
    Share this post
    • Share to Facebook
    • Share to Twitter
    • Share to Google+
    • Share to Stumble Upon
    • Share to Evernote
    • Share to Blogger
    • Share to Email
    • Share to Yahoo Messenger
    • More...

    0 comments:

    Post a Comment

    :) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
    Click to see the code!
    To insert emoticon you must added at least one space before the code.