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
3
using namespace
std;
4
5
void
swap
(
int
* x,
int
* y)
6
{
7
int
temp = *x;
8
*x = *y;
9
*y = temp;
10
}
11
12
13
int
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
}
swap
void swap(int *x, int *y)
Definition
swap_by_pointers.cpp:5
main
int main()
Definition
swap_by_pointers.cpp:13
Module8
Sample Code
Pointers
swap_by_pointers.cpp
Generated on Sun Sep 29 2024 16:39:53 for COMP2113 by
1.12.0