/* --------------------------------------------------------------------- ** Figure 12.7: A swap function with an error. ** --------------------------------------------------------------------- */ #include "tools.h" void badswap( double f1, double f2 ); void main( void ) { double x = 10.2, y = 7; printf( "Before badswap: x=%5.1g y=%5.1g\n", x, y ); badswap( x, y ); printf( "After badswap: x=%5.1g y=%5.1g\n", x, y ); } /* ---------------------------------------------------- */ void badswap( double f1, double f2 ) { double swapper = f1; f1 = f2; f2 = swapper; } /* Output --------------------------------- Before badswap: x= 10.2 y= 7.0 After badswap: x= 10.2 y= 7.0