// 24T3 COMP1511 Week 5 Lecture 2 // variables/data are passed into functions by value // a copy of the value gets passed into the function // so changes made in the function are on the local copy #include void update(int x, int y); void swap(int x, int y); int main(void) { int x = 2; int y = 5; printf("%d %d\n", x, y); update(x,y); printf("%d %d\n", x, y); swap(x, y); printf("%d %d\n", x, y); return 0; } // This function will only modify the local copy of x and y void update(int x, int y) { x = x + 1; y = y - 1; } // This function will only modify the local copy of x and y void swap(int x, int y) { int tmp = x; x = y; y = tmp; }