Advertisement
valiamaximova1

Math operation cilinder

Apr 3rd, 2021
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3.  
  4. int main()
  5. {
  6.     float r, h, S, V;
  7.     printf("Enter radius: ");
  8.     scanf("%f", &r);
  9.     printf("Enter height: ");
  10.     scanf("%f", &h);
  11.    
  12.     if (r <= 0 || h <= 0)
  13.     {
  14.         printf("Numbers can't be negative!\n");
  15.         return 1;
  16.     }
  17.    
  18.     S = M_PI * r *r;
  19.     V = M_PI * r * r * h;
  20.     printf("S = %.2f\n", S);
  21.     printf("V = %.2f\n", V);
  22.     return 0;  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement