Make a program for finding the area of a triangle using Heron’s formula.
Make a program for finding the area of a triangle using Heron’s formula. The input data is the length of the sides of the triangle. Output data perimeter of a triangle, area of a triangle.
program zz1;
var a, b, c, S, p, d: real; // set variables of non-integer type
begin
write (‘enter the first side of the triangle’);
read (a);
write (‘enter the second side of the triangle’);
read (b);
write (‘enter the third side of the triangle’);
read (c);
d: = (a + b + c) / 2; // find the semi-perimeter of the triangle
write (‘triangle perimeter =’, d * 2);
if (a + b> c) or (a + c> b) or (c + b> a) // check for the existence of a triangle, if exists, then calculate the area
then begin s: = sqrt (d * (d-a) * (d-b) * (d-c)); write (‘area of triangle =’, s: 5: 2); end
else write (‘triangle does not exist’);
end.