fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int a = 5, b = 10, temp;
  7.  
  8. cout << "Before swapping." << endl;
  9. cout << "a =" << a << ", b =" << b << endl;
  10.  
  11. temp = a;
  12. a = b;
  13. b = temp;
  14.  
  15. cout << "\nAfter swapping." << endl;
  16. cout << "a =" << a << ", b =" << b << endl;
  17.  
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0.01s 5556KB
stdin
234
stdout
Before swapping.
a =5, b =10

After swapping.
a =10, b =5