Jumat, 04 Desember 2009

Dasar Dasar C++ "Bg. IV"



#include <iostream.h>
#include <conio.h>

void TukarAB(int &a, int &b)
{
            int temp;
   temp = a;
   a=b;
   b=temp;
   cout<<"Dalam fungsi TukarAB, nilai a= "<<a<<" nilai b =
"<<b<<endl;
}

int main()
{
            int a, b;
   cout<<"Masukkan nilai a = "; cin>>a;
   cout<<"Masukkan nilai b = "; cin>>b;
   cout<<"Nilai a dan b sebelum masuk fungsi TukarAB ";
   cout<<"a= "<<a<<" b= " <<b<<endl;;

   TukarAB(a, b);
   cout<<"Nilai a dan b sesudah keluar fungsi tukarAB, ";
   cout<<"a = "<<a<<" b= "<<b<<endl;
   getch();
   return(0);
}




Tidak ada komentar: