Skip to main content

Compute area of Circle,Squar,Triangle

#include<stdio.h>
int main()
{
    char ch;

    printf("Enter c to compute area of Circle\n");
    printf("Enter s to compute area of Square\n");
    printf("Enter c to compute area of Triangle\n");

    ch=getchar();
    printf("\n");

    if(ch=='c')
    {
        printf("Enter radius of circle : ");
        scanf("%f",&s1);
        printf("Area is : %f ",3.1416*radius*radius);
    }
    else if(ch=='s')
    {
        printf("Enter Length of first side : ");
        scanf("%f",&s1);
        printf("Enter Length of second side : ");
        scanf("%f",&s2);
        printf("Area is : %f ",s1*s2);
    }
    else if(ch=='t')
    {
        printf("Enter length of base : ");
        scanf("%f",&s1);
        printf("Enter length of hight : ");
        scanf("%f",&s2);
        printf("Area is : %f",(s1*s2)/2.0);
    }

    return 0;
}

Comments

Popular posts from this blog

  Good becomes great, bad becomes worse. A strong man who has known power all his life can lose respect for that power, but a weak man knows the value of strength and knows compression

Finding digit number of a number

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 #include<stdio.h> int main() { long long int a,b, sum ,temp,count = 0 ,count_1 = 1 ; while ( (scanf( "%lld %lld" , & a, & b)) != EOF) { if (a <= 1000000 && b <= 1000000 ) { sum = a + b; temp = sum ; while (temp != 0 ) { sum /= 10 ; temp = sum ; count ++ ; } printf( "%lld \n " ,count); } count = 0 ; if (count_1 > 200 ) break ; count_1 ++ ; } return 0 ; }