fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void Swap(int& a, int& b);
  5.  
  6. int main() {
  7. int a = 5;
  8. int b = 10;
  9.  
  10. Swap(a, b);
  11.  
  12. cout << "a = " << a << " b = " << b;
  13.  
  14. return 0;
  15. }
  16.  
  17. void Swap(int& a, int& b)
  18. {
  19. int temp = a;
  20. a = b;
  21. b = temp;
  22. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
a = 10 b = 5