// test swap function // #include #include void badswap( int x, int y) { int t = x; x = y; y = t; } void goodswap( int *x, int *y) { int t = *x; *x = *y; *y = t; } int main( void) { int a = 5, b = 10; printf( " before swap: a = %i, b = %i\n", a, b); badswap( a, b); printf( " after badswap: a = %i, b = %i\n", a, b); goodswap( &a, &b); printf( "after goodswap: a = %i, b = %i\n", a, b); return 0; } /* output: before swap: a = 5, b = 10 after badswap: a = 5, b = 10 after goodswap: a = 10, b = 5 */