COMP2113
COMP2113_ENGG1340 Programming technologies and Computer programming II [Section 2BC] [2023]
Loading...
Searching...
No Matches
swap_by_pointers.cpp File Reference
#include <iostream>
Include dependency graph for swap_by_pointers.cpp:

Go to the source code of this file.

Functions

int main ()
 
void swap (int *x, int *y)
 

Function Documentation

◆ main()

int main ( void )

Definition at line 13 of file swap_by_pointers.cpp.

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)

References swap().

Here is the call graph for this function:

◆ swap()

void swap ( int * x,
int * y )

Definition at line 5 of file swap_by_pointers.cpp.

6{
7 int temp = *x;
8 *x = *y;
9 *y = temp;
10}

Referenced by main().

Here is the caller graph for this function: