
![]() |
F U N C T I O N S W A P
Wednesday, 26 February 2014 | 07:44 | 0 Cintaku Amira
Assalamualaikum..
Okay
for today, mira just nak share contoh coding C++ untuk buat function swap..
Hope
semua boleh faham k..
#include <iostream> #include <conio> void main() { int a, b; void swap(int &, int &); cout<<"\n\nPlease Enter any two number : "; cout<<"\nNumber 1 : "; cin>>a; cout<<"\nNumber 2 : "; cin>>b; swap(a, b); cout<<"\nThe value after swap is : "; cout<<"\nNumber 1 is "<<a; cout<<"\n"; cout<<"\nNumber 2 is "<<b; getch(); } void swap(int &a, int &b) { int c; c = a; a = b; b = c; return; }
Sekian
terima kasih J
|