fork download
  1. #include <iostream>
  2.  
  3. void switchVar (int & x, int & y) {x+=y; y = x-y; x=x-y;}
  4.  
  5. int main () {
  6. int x = 3, y= 4;
  7. switchVar(x, y);
  8. std::cout << "X is: " << x << std::endl << "Y is: " << y << std::endl;
  9. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
X is: 4
Y is: 3