Advertisement
zenados

Circumference

Sep 14th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.     int diameter;
  5.     //note the comma at the end
  6.     const double PI = 22/7.0; //use this PI value
  7.     /**Note This also works:
  8.     const double PI = 22.0/7
  9.     const double PI = 22.0/7.0
  10.     */
  11.  
  12.     printf("Input diameter: ");
  13.     scanf("%d", &diameter); //get the radius of the cylinder
  14.  
  15.     printf("PI: %lf\n", PI); //Output the value for PI(22/7)
  16.  
  17.     double circumference = PI*diameter; //calculate the circumference
  18.     printf("Circumference: %lf\n", circumference); //output the result
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement