#include void swap ( double* , double* ); /* just a prototype */ void swap ( double* p, double* q ) { double temp; temp = *p; *p = *q; *q = temp; } int main ( int argc, char* argv[] ) { double a = 10.1; double b = -2.1; double* pa; double* pb; double* ptemp; printf( "\nThis is the output from %s:", argv[0] ); printf( "\nThe command line has %d arguments\n\n", argc); printf( "To begin, a is %5.1f, b is %5.1f\n", a, b ); swap( &a, &b ); printf( "After swap(&a, &b), a is %5.1f, b is %5.1f\n", a, b ); pa = &a; pb = &b; printf( "\nNow pa points to an object with value %5.1f," "\nand pb points to an object with value %5.1f\n", *pa, *pb ); swap( pa, pb ); printf( "After swap(pa, pb), a is %5.1f, b is %5.1f\n", a, b ); printf( "And pa points to an object with value %5.1f," "\nand pb points to an object with value %5.1f\n", *pa, *pb ); ptemp = pa; pa = pb; pb = ptemp; printf( "\nAfter swaping pa and pb,\npa points to an object with value %5.1f," "\nand pb pointss to an object with value %5.1f\n", *pa, *pb ); printf( "But a is %5.1f, b is %5.1f\n", a, b ); return (0); } /* This is the output from pointer-1: The command line has 1 arguments To begin, a is 10.1, b is -2.1 After swap(&a, &b), a is -2.1, b is 10.1 Now pa points to an object with value -2.1, and pb points to an object with value 10.1 After swap(pa, pb), a is 10.1, b is -2.1 And pa points to an object with value 10.1, and pb points to an object with value -2.1 After swaping pa and pb, pa points to an object with value -2.1, and pb points to an object with value 10.1 But a is 10.1, b is -2.1 */