Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <math.h>
  4.  
  5. #ifndef M_PI
  6. #define M_PI 3.14159265358979323846
  7. #endif
  8.  
  9. double cylindervolume(double radius, double height)
  10. {
  11.     return M_PI*radius*radius*height;
  12. }
  13.  
  14. int main()
  15. {
  16.     double r = 1.0, h = 1.0;
  17.     printf("Cylinder Volume Calculation\n\n");
  18.     while (r > 0.0 && h > 0.0)
  19.     {
  20.         printf("Input the radius: ");
  21.         scanf("%lf", &r);
  22.         printf("Input the height: ");
  23.         scanf("%lf", &h);
  24.         printf("\nVolume = %g\n\n",cylindervolume(r, h));
  25.     }
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement