Commit 96d51440 authored by Tony Cheung's avatar Tony Cheung

Upload New File

parent 74e75418
#include <iostream>
using namespace std;
void swap(int &x, int &y)
{
int t = x;
x = y;
y = t;
cout << "In the swap(), the value of x is: " << x << endl;
cout << "In the swap(), the value of y is: " << y << endl;
}
int main()
{
int a = 1;
int b = 2;
cout << "Before calling swap(), the value of a is: " << a << endl;
cout << "Before calling swap(), the value of b is: " << b << endl;
swap(a, b);
cout << "After calling swap(), the value of a is: " << a << endl;
cout << "After calling swap(), the value of b is: " << b << endl;
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment