Modularisasi C++

Tuesday, March 29, 2011 7:50 AM by Computer and Programming
//Program Coba Modularisasi
#include<conio.h>
#include<iostream.h>

void Hitung_Volume(float p,float l,float t )
    {
    float Volume;
    Volume = p*l*t;
    cout << " \n\nVolume Kubus = "<< Volume << "\n";
    }
void Hitung_Luas(float p,float l )
    {


    float Luas;
    Luas = p*l;
    cout << " \n\nLuas Persegi = "<< Luas << "\n";}
main(){
float p,l,t;
int n;
cout<< "\n\tAyo beLajar Matematika ";
cout<< "\n\nMasukkan panjang = "; cin>>p;
cout<< "\n\nMasukkan lebar = "; cin>>l;
cout<< "\n\nMasukkan tinggi = "; cin>>t;
cout<< "\n\nMasukkan pilihan \n\n1 = Hitung Volume Kubus \n\n2 = Hitung Luas Persegi : ";
        cin>>n;
if
(n==1)
Hitung_Volume(p,l,t);
else if
(n==2)
Hitung_Luas(p,l);
else
cout << "\n\nSalah Tombol ";
getch();
}

0 Response to "Modularisasi C++"

Post a Comment