Tugas
0

Program tukar

Rabu, 24 Oktober 2012
Share this Article on :

Program Tukar

01#include <iostream>
02 
03using namespace std;
04 
05void tukar(int *A, int *B){
06    int temp;
07    temp=*A;
08    *A=*B;
09    *B=temp;
10    }
11     
12int main(){
13    int A,B;
14    cout<<"Masukkan nilai A = ";
15    cin>>A;
16    cout<<"Masukkan nilai B = ";
17    cin>>B;
18    cout<<"Sebelum ditukar"<<endl;
19    cout<<"A : "<<A<<endl;
20    cout<<"B : "<<B<<endl;
21    cout<<"Sesudah ditukar"<<endl;
22    tukar(&A,&B);
23    cout<<"A : "<<A<<endl;
24    cout<<"B : "<<B;
25    cout<<endl;
26    system("PAUSE");
27    return 0;
28    }


Artikel Terkait:

0 komentar:

Posting Komentar