Program Tukar
01 | #include <iostream> |
02 |
03 | using namespace std; |
04 |
05 | void tukar(int *A, int *B){ |
06 | int temp; |
07 | temp=*A; |
08 | *A=*B; |
09 | *B=temp; |
10 | } |
11 | |
12 | int 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 | } |

0 komentar:
Posting Komentar