C program to find area of triangle using heron's formula

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main(){
float area,a,b,c,s;
clrscr();
printf("Heron's Formula \n enter sides of a triangle\n");
scanf("%f%f%f",&a,&b,&c);
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
if(area!=0)
printf("area of triangle= %f\n",area);
else
printf("these sides can not form a triangle\n");
getch();
}

No comments:

Post a Comment