fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int a, b;
  7. cout << "Enter two numbers: ";
  8. cin >> a >> b;
  9.  
  10. a = a + b;
  11. b = a - b;
  12. a = a - b;
  13.  
  14. cout << "After swapping:\n";
  15. cout << "a = " << a << endl;
  16. cout << "b = " << b << endl;
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0.01s 5284KB
stdin
12
13
stdout
Enter two numbers: After swapping:
a = 13
b = 12