/* --------------------------------------------------------------------- // Figure 9.8: A function with two parameters and a return value. // --------------------------------------------------------------------- */ #include "tools.h" double cyl_vol( double d, double h ); /* function prototype */ /*-----------------------------------------------------------------------*/ void main( void ) { double diam, height, volume; banner(); printf ( "\n Enter diameter and height of cylinder: " ); scanf ( "%lg%lg", &diam, &height ); volume = cyl_vol( diam, height ); printf ( "\t The volume of this cylinder = %.2f \n", volume ); bye(); } /*-----------------------------------------------------------------------*/ double /* We return the volume of a cylinder */ cyl_vol( double d, double h ) /* with diameter=d and height=h; */ { double r; /* r is the radius of the cylinder. */ r = d / 2; return PI * r * r * h; }