Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
1.2 kB
5
Indexable
Never
/*                    */
/* BERSUN SEZIN DEMIR */
/*                    */

#include <stdio.h>
#include <math.h>
 
void main()
{
    int s, a, b, c, area;
    int choose;
    
    printf("Which one's area do you want to calculate? (1-Triangle , 2-Rectangle, 3-Circle): ");
    scanf("%d", &choose);
    
    if(choose == 1){
        printf("Enter the values of a, b and c \n");
        scanf("%d %d %d", &a, &b, &c);
        s = (a + b + c) / 2;
        area = sqrt(s * (s - a) * (s - b) * (s - c));
        printf("Area of a triangle = %d \n", area);
    }
    
    if(choose == 2){
        int length, breadth, area;
 
        printf("\nEnter the Length of Rectangle : ");
        scanf("%d", &length);
 
        printf("\nEnter the Breadth of Rectangle : ");
        scanf("%d", &breadth);
 
        area = length * breadth;
        printf("\nArea of Rectangle : %d", area);
    }
    
    if(choose == 3){
        float radius, area;  
        printf("Enter radius of circle\n");  
        scanf("%f", & radius);  
        area = (3.14) * radius * radius;  
        printf("Area of circle : %0.4f\n", area);  
        getch();  
        return 0; 
    }
}