COMP2113
COMP2113_ENGG1340 Programming technologies and Computer programming II [Section 2BC] [2023]
Loading...
Searching...
No Matches
swap_by_pointers.cpp
Go to the documentation of this file.
1#include <iostream>
2
3using namespace std;
4
5void swap( int * x, int * y)
6{
7 int temp = *x;
8 *x = *y;
9 *y = temp;
10}
11
12
13int main()
14{
15 int a = 2, b = 3;
16
17 cout << a << ' ' << b << endl;
18
19 swap(&a, &b);
20 cout << a << ' ' << b << endl;
21
22
23 return 0;
24}
void swap(int *x, int *y)
int main()