# include int iran ( int a, int b, int *seed ); // // In this example, we don't know the values of A, B, and C. // We want to find the maximum. // int main ( ) { int a; int b; int c; int max; int seed; // // To make this fair, we set A, B, and C randomly. // To keep things interesting, we let the "seed" depend on the current time. // seed = time ( 0 ); a = iran ( 0, 100, &seed ); b = iran ( 0, 100, &seed ); c = iran ( 0, 100, &seed ); printf ( "Starting out, (A,B,C) = (%i,%i,%i)\n", a, b, c ); // // Imagine that A is the maximum. // printf ( "MAX = %i = A\n", a ); max = a; // // If B is bigger, then it's the maximum. // if ( max < b ) { printf ( "MAX = %i < %i = B is bigger, so reset MAX\n", max, b ); max = b; } // // If C is bigger, then it's the maximum. // if ( max < c ) { printf ( "MAX = %i < %i = C is bigger, so reset MAX\n", max, c ); max = c; } printf ( "\n" ); printf ( " The maximum of (%i,%i,%i) is %i\n", a, b, c, max ); return 0; }