// Demonstrates parameter passing in C // Compile: gcc -o swaptest swaptest.c // Execute: swaptest // #include int main(int argc, char *argv[]) { // Designate the params as by reference void swap(int *x, int *y) { int t = *x; // Explicit dereference *x = *y; *y = t; } printf("swaptest.c, by reference\n"); int a = 1; int b = 2; printf("%d, %d\n", a, b); // Pass the addresses of a and b swap(&a, &b); printf("%d, %d\n", a, b); }