fork download
  1.  
  2. #include <stdio.h>
  3.  
  4. #define PI 3.14 /* define the value of PI as a constant */
  5.  
  6. float square (float number)
  7. {
  8. float square_value;
  9.  
  10. square_value = number * number;
  11.  
  12. return (square_value);
  13.  
  14. }
  15.  
  16. float area_of_circle (float radius)
  17. {
  18.  
  19. float area; /* area of a circle */
  20.  
  21. /* compute area of a circle: PI * radius squared */
  22. area = PI * square(radius);
  23.  
  24. return (area);
  25. }
  26.  
  27. main ()
  28. {
  29.  
  30. float area; /* the area of the circle */
  31. float radius; /* radius of a circle to be entered */
  32.  
  33. printf ("Enter the circle radius: ");
  34. scanf ("%f", &radius);
  35.  
  36. /* Pass value1 to the square function, process it and return the */
  37. /* the squared value into the answer local variable */
  38. area = area_of_circle (radius);
  39.  
  40. printf ("The Area of a Circle with a radius of %5.2f is %10.2f \n", radius, area);
  41.  
  42. return (0);
  43.  
  44. }
Success #stdin #stdout 0.01s 5280KB
stdin
4.5
stdout
Enter the circle radius: The Area of a Circle with a radius of  4.50 is      63.58