Wednesday, 30 November 2016

AREA OF TRIANLGE



#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i;
float a,b,c,area,s,l,m;
printf("enter 1 for using Heron's formula 2 for general formula\n");
scanf("%d",&i);
switch(i)
{
case 1:
    printf("enter the value of three sides of the triangle\n");
    scanf("%f%f%f",&a,&b,&c);
    s=(a+b+c)/2;
    area=sqrt(s*(s-a)*(s-b)*(s-c));
    printf("AREA OF TRIANGLE=%f",area);
    break;
case 2:
    printf("enter the base and height of the triangle\n");
    scanf("%f%f",&l,&m);
    area=(0.5)*l*m;
    printf("area of the triangle is %f", area);
    break;
default:
    printf("SEE YOU SOON\n BYE");
    break;
}

}

No comments:

Post a Comment