Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- int diameter;
- //note the comma at the end
- const double PI = 22/7.0; //use this PI value
- /**Note This also works:
- const double PI = 22.0/7
- const double PI = 22.0/7.0
- */
- printf("Input diameter: ");
- scanf("%d", &diameter); //get the radius of the cylinder
- printf("PI: %lf\n", PI); //Output the value for PI(22/7)
- double circumference = PI*diameter; //calculate the circumference
- printf("Circumference: %lf\n", circumference); //output the result
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement