fork download
  1. /* A program to figure out the three defining aspects of a Circle */
  2.  
  3. #include <stdio.h>
  4.  
  5. #define PI 3.1416
  6.  
  7. /* Function Prototypes */
  8. float circleCircumference (float Diameter);
  9. float circleRadius (float Circumference);
  10. float circleDiameter (float Circumference);
  11.  
  12. int main ( )
  13. {
  14.  
  15. float circumference; /* circumference of a circle */
  16. float diameter; /* diameter of a circle */
  17. float radius; /* radius of a circle */
  18.  
  19. printf ("Enter the Circumference in Centimeters: ");
  20. scanf ("%f", &circumference);
  21.  
  22. diameter = circleDiameter (circumference);
  23. radius = circleRadius (circumference);
  24.  
  25. /* calculate the Diameter and Radius based on the Circumference */
  26. printf ("\nThe Diameter of our Circle is: %5.1f \n", diameter);
  27. printf ("The Radius of our Circle is %5.1f \n", radius);
  28.  
  29. printf ("The Circumference given the Diameter %5.1f is %5.1f \n",
  30. diameter, circleCircumference (diameter));
  31.  
  32. return (0);
  33.  
  34. } /* main */
  35.  
  36. // ***********************************************************************
  37. // Function: circleCircumference
  38. //
  39. // Description: Calculates the Circumference of a Circle
  40. // given the Diameter of a Circle
  41. //
  42. // Parameters: Diameter - The Diameter of the Circle
  43. //
  44. // Returns: Circumference - The Circumference of a Circle
  45. // ***********************************************************************
  46. float circleCircumference (float Diameter)
  47. {
  48. return (PI * Diameter);
  49. }
  50.  
  51. // ***********************************************************************
  52. // Function: circleRadius
  53. //
  54. // Description: Calculates the Radius of a Circle
  55. // given the Circumference of a Circle
  56. //
  57. // Parameters: Circumference - The Circumference of the Circle
  58. //
  59. // Returns: Radius - The Radius of a Circle
  60. // ***********************************************************************
  61. float circleRadius (float Circumference)
  62. {
  63. return (Circumference / (2 * PI));
  64. }
  65.  
  66. // ***********************************************************************
  67. // Function: circleDiameter
  68. //
  69. // Description: Calculates the Diameter of a Circle
  70. // given the Circumference of a Circle
  71. //
  72. // Parameters: Circumference - The Circumference of the Circle
  73. //
  74. // Returns: Diameter - The Diameter of a Circle
  75. // ***********************************************************************
  76. float circleDiameter (float Circumference)
  77. {
  78. return (Circumference / PI);
  79. }
Success #stdin #stdout 0s 5320KB
stdin
1000
stdout
Enter the Circumference in Centimeters: 
The Diameter of our Circle is: 318.3 
The Radius of our Circle is 159.2 
The Circumference given the Diameter 318.3 is 1000.0