/*------------------------------------------------------------------------- // Figure 9.18: First draft of main() for the fin program. // Figure 9.21: Fin program: first draft of print_table() function. // ------------------------------------------------------------------------- */ #include "tools.h" void print_table ( float n ); void main( void ) { float len; /* The length of the cooling fin. */ banner(); puts( " Temperature Along a Rectangular Cooling Fin" ); printf( " Please enter the length of the fin in meters: " ); scanf( "%g", &len ); print_table( len ); bye(); } /* ------------------------------------------------------------------ ** Print a table of temperatures for a fin that is N meters long. ** N must be greater than 0. */ void print_table ( float N ) { float x; /* Current distance from wall. */ float temp; /* Temperature at distance x from wall. */ const float step = .005; /* Step size for loop. */ const float epsilon = step/2.0; /* For floating comparison to end loop. */ printf( "\n Distance from base (m) Temperature (C) \n" " ---------------------- --------------- \n" ); for (x = 0.0; x < N + epsilon; x += step) { temp = 1.1; /* compute_temp ( x ); */ printf( "%12.3f %24.1f \n", x, temp ); } printf( " ---------------------- --------------- \n" ); }