Advertisement
valve2

Circle A&R

Feb 24th, 2023 (edited)
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2. int main(){
  3.     float pie = 3.1415;
  4.     float radius;
  5.     int op;
  6.     printf("Enter 1 to calc circumference, 2 to calc area\n");
  7.     scanf_s("%d", &op);
  8.     if (op == 1){
  9.         printf("enter the Radius\n");
  10.         scanf_s("%fl", &radius);
  11.         float circ = 2 * pie * radius;
  12.         printf ("circumference: %fl\n", circ);
  13.     }
  14.     else if (op == 2){
  15.         printf("Enter the Radius\n");
  16.         scanf_s("%fl", &radius);
  17.         float area = pie * radius * radius;
  18.         printf("Area: %fl\n", area);
  19.     }
  20.     else if(op != 1 && op != 2){
  21.         printf("operation invalid\n");
  22.         return 0;
  23.     }
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement