/*Hero's Formula is
Area=squarerootof(S(S-a)(S-b)( S-c) where a,b,c are the sides of triangle and S=(a+b+c)/2 is the semi-perimeter of triangle.*/
#include<iostream.h>
#include<conio.h>
#include<math.h>//Function Definition
float area(float p, float q, float r)
{
float s, mult, sq;
s=(a+b+c)/2;
mult=s*(s-a)*(s-b)*(s-c);
sq=sqrt(mult); //sqrt() is defined in math.h and used to find square root of given number
return(sq);
}
void main()
{
float a,b,c,ans;
float area(float,float,float); //Prototype or Function Declaration
clrscr();
printf("\n Enter the First Side of Triangle");
scanf("%f",&a);
printf("\n Enter the Second Side of Triangle");
scanf("%f",&b);
printf("\n Enter the Third Side of Triangle");
scanf("%f",&c);
ans=area(a,b,c); //Calling function for a,b,c;
printf("\n Area of Give Triangle is =%.2f,ans);
getche();
}
Area=squarerootof(S(S-a)(S-b)(
#include<iostream.h>
#include<conio.h>
#include<math.h>//Function Definition
float area(float p, float q, float r)
{
float s, mult, sq;
s=(a+b+c)/2;
mult=s*(s-a)*(s-b)*(s-c);
sq=sqrt(mult); //sqrt() is defined in math.h and used to find square root of given number
return(sq);
}
void main()
{
float a,b,c,ans;
float area(float,float,float); //Prototype or Function Declaration
clrscr();
printf("\n Enter the First Side of Triangle");
scanf("%f",&a);
printf("\n Enter the Second Side of Triangle");
scanf("%f",&b);
printf("\n Enter the Third Side of Triangle");
scanf("%f",&c);
ans=area(a,b,c); //Calling function for a,b,c;
printf("\n Area of Give Triangle is =%.2f,ans);
getche();
}
2 comments:
Its heron's formula.....hero's formula....funny...:)
Its known by both name, Hero or Heron!
Post a Comment