Advertisement
Guest User

Untitled

a guest
Sep 9th, 2012
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.63 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <windows.h>
  4.  
  5. void calsquare(void);
  6. void calcone(void);
  7. void calcircle(void);
  8.  
  9. int main()
  10. {
  11.  
  12.     int y = 0;
  13.  
  14.     printf("Menu\n");
  15.     printf("1. Find Area and Perimeter of Square\n");
  16.     printf("2. Find Area and Perimeter of Cone\n");
  17.     printf("3. Find Area and Perimeter of a Circle\n");
  18.     printf("4. Quit\n");
  19.     printf("Input the following function\n");
  20.     scanf("%d", &y);
  21.  
  22.     if (y == 1) {
  23.     calsquare();
  24.     }
  25.  
  26.     if (y == 2) {
  27.     calcone();
  28.     }
  29.  
  30.     if (y == 3) {
  31.     calcircle();
  32.     }
  33.  
  34.     if (y == 4) {
  35.     system("EXIT");
  36.     }
  37. }
  38.      
  39. void calsquare(void)
  40. {
  41.  
  42.     float area = 0;
  43.     float perimeter = 0;
  44.     float x = 0;
  45.     system("CLS");
  46.  
  47.     printf("Input the side of x : ");
  48.     scanf("%f", &x);
  49.  
  50.     area = (x*x);
  51.     perimeter = (4*x);
  52.  
  53.     printf("Area of square = %.2f\n", area);
  54.     printf("Perimeter of square = %.2f\n", perimeter);
  55.  
  56.     //getch();
  57. }
  58.  
  59. void calcone(void)
  60. {
  61.  
  62.     float area = 0;
  63.     float volume = 0;
  64.     float s = 0, r = 0, h = 0;
  65.  
  66.     system("CLS");
  67.     printf("Input the side of s : ");
  68.     scanf("%f", &s);
  69.  
  70.     printf("Input the side of r : ");
  71.     scanf("%f", &r);
  72.  
  73.     printf("input the side of h");
  74.     scanf("%f", &h);
  75.  
  76.     area = (3.142*r*s)+(3.142*r*r);
  77.     volume = (1/3)*(3.142*r*r*h);
  78.  
  79.     printf("Area of cone = %.2f\n", area);
  80.     printf("Volume of cone = %.2f\n", volume);
  81.  
  82.     //getch();
  83. }
  84.  
  85. void calcircle(void)
  86. {
  87.  
  88.     float area = 0;
  89.     float perimeter = 0;
  90.     float r = 0;
  91.  
  92.     system("CLS");
  93.     printf("Input the side of r : ");
  94.     scanf("%f", &r);
  95.  
  96.     area = (3.142*r*r);
  97.     perimeter= (2*3.142*r);
  98.  
  99.     printf("Area of cone = %.2f\n", area);
  100.     printf("Perimeter of cone = %.2f\n", perimeter);
  101.  
  102.     //getch();
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement