// nama program : clokal_eksternal.cpp
// contoh program variabel lokal dan eksternal
# include <iostream.h>
int data = 100; // variabel eksternal
void fungsi_satu (); // prototipe fungsi
void fungsi_dua ();
void main ()
{
int data = 200; // variabel lokal main
fungsi_satu();
fungsi_dua();
cout<< " nilai data lokal main "<<data<<endl;
}
void fungsi_satu()
{
int data = 300; // variabel lokal fungsi_satu
cout<< " nilai data lokal satu "<<data<<endl;
}
void fungsi_dua()
{
cout<< " nilai data eksternal "<<data<<endl;
}
output
nilai data lokal satu 300
nilai data eksternal 100
nilai data lokal main 200
Friday, 13 January 2012
CPP
0 Response to "contoh 34"
Post a Comment