Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- float squareS(int* a){
- return (*a) * (*a);
- }
- float rectS(int* a, int* b){
- return (*a) * (*b);
- }
- float triangleS(int* a, int* h){
- return ((*a) * (*h)) /2;
- }
- float circleS(int* r){
- return M_PI * (*r) * (*r);
- }
- int main()
- {
- printf("Input number of the figure you want: \n1. Square\n2. Rectangle\n3. Rectangular triangle\n4. Circle\n");
- int num;
- scanf("%d", &num);
- int a;
- int b;
- int h;
- int r;
- float s;
- if(num == 1){
- printf("Input side of the square:\n");
- scanf("%d", &a);
- s = squareS(&a);
- printf("%.2f", s);
- }else if(num == 2){
- printf("Input sides of the rectangle:\n");
- scanf("%d %d", &a, &b);
- s = rectS(&a, &b);
- printf("%.2f", s);
- }else if(num == 3){
- printf("Input side and height of the triangle:\n");
- scanf("%d %d", &a, &h);
- s = triangleS(&a, &h);
- printf("%.2f", s);
- }else if(num == 4){
- printf("Input radius of the circle:\n");
- scanf("%d", &r);
- s = circleS(&r);
- printf("%.2f", s);
- }else{
- printf("Wrong number!");
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment