Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #include <windows.h>
- void calsquare(void);
- void calcone(void);
- void calcircle(void);
- int main()
- {
- int y = 0;
- printf("Menu\n");
- printf("1. Find Area and Perimeter of Square\n");
- printf("2. Find Area and Perimeter of Cone\n");
- printf("3. Find Area and Perimeter of a Circle\n");
- printf("4. Quit\n");
- printf("Input the following function\n");
- scanf("%d", &y);
- if (y == 1) {
- calsquare();
- }
- if (y == 2) {
- calcone();
- }
- if (y == 3) {
- calcircle();
- }
- if (y == 4) {
- system("EXIT");
- }
- }
- void calsquare(void)
- {
- float area = 0;
- float perimeter = 0;
- float x = 0;
- system("CLS");
- printf("Input the side of x : ");
- scanf("%f", &x);
- area = (x*x);
- perimeter = (4*x);
- printf("Area of square = %.2f\n", area);
- printf("Perimeter of square = %.2f\n", perimeter);
- //getch();
- }
- void calcone(void)
- {
- float area = 0;
- float volume = 0;
- float s = 0, r = 0, h = 0;
- system("CLS");
- printf("Input the side of s : ");
- scanf("%f", &s);
- printf("Input the side of r : ");
- scanf("%f", &r);
- printf("input the side of h");
- scanf("%f", &h);
- area = (3.142*r*s)+(3.142*r*r);
- volume = (1/3)*(3.142*r*r*h);
- printf("Area of cone = %.2f\n", area);
- printf("Volume of cone = %.2f\n", volume);
- //getch();
- }
- void calcircle(void)
- {
- float area = 0;
- float perimeter = 0;
- float r = 0;
- system("CLS");
- printf("Input the side of r : ");
- scanf("%f", &r);
- area = (3.142*r*r);
- perimeter= (2*3.142*r);
- printf("Area of cone = %.2f\n", area);
- printf("Perimeter of cone = %.2f\n", perimeter);
- //getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement