#include #define PI 3.1415926 #define SQUARE(x) ( ( x ) * ( x ) ) /* circle area by: A. C. Programmer date started: 12 Sept 97 last updated: 2 Oct 97 */ /* @ExplainProgram()@ explains the purpose of the program, displaying this on the screen of the computer */ void ExplainProgram( void ) { printf( "This program calculates the area of a circle. \n" ); printf( "Enter the value of the radius and press \n" ); printf( "\n" ); } /* @GetValue()@ prompts user to enter radius. Returns the value as a float. */ float GetValue( void ) { float inputValue; /* value entered by user */ printf( "Value of the radius: " ); scanf( "%f", &inputValue ); return inputValue; } /* @CircleArea()@ calculates the area of a circle. Returns the value as a float. */ float CircleArea( float radius ) { float area; /* area of the circle */ area = PI * SQUARE( radius ); return area; } /* @DisplayAnswer()@ displays the area of the circle on the screeen. */ void DisplayAnswer( float area ) { printf( "\n\n" ); /* two blank lines */ printf( "The area of the circle is %f square units.\n", area ); } int main( void ) { float radius; float area; ExplainProgram(); /* explains program to user */ radius = GetValue(); /* get radius from user */ area = CircleArea( radius ); /* compute the circle area */ DisplayAnswer( area ); /* display the answer */ }