/* -------------------------------------------------------------------------- ** Chapter 15, Using the Computer Exercise 1: Files. ** -------------------------------------------------------------------------- */ #include "tools.h" #define x_init 0.0 #define x_final 1.0 double f( double x ){ return pow( x, 3 ) - pow( x, 2 ) - 3 * x + 12 ; } /* -------------------------------------------------------------------------- */ void main ( void ) { double x, y; /* Delete the #defines for x_init and x_final. */ /* Declare x_init and x_final as int variables. */ /* Declare an integer variable for the error code returned by fscanf(). */ /* Declare streams for your input and output files. */ banner(); /* Open your input and output files. Exit if either statement faiils. */ /* Read values from your input file for x_init and x_final. */ /* Exit with an appropriate message if there is a read error. */ /* Change the next line to use your output stream instead of stdout. */ printf( "\n x y \n\n" ); for (x = x_init; x <= x_final; x += 0.1 ) { y = f( x ); /* Change the next line to use your output stream instead of stdout. */ printf( "%8.2f %15.2f \n", x, y ); } /* Close your streams. */ bye(); }