Area of a triangle is calculated by the following Mathematical formula,
(base * height) / 2 = Area
Program to calculate area of triangle with base as 10 and height as 15 is shown.
$base = 10;
$height = 15;
echo "area with base $base and height $height= " . ($base * $height) / 2;
Program to calculate area of triangle by inserting values in the form is shown.
<form method = "post">
Base: <input type="number" name="base">
Height: <input type="number" name="height"><br>
<input type = "submit" name = "submit" value="Calculate">
$base = $_POST['base'];
$height = $_POST['height'];
$area = ($base*$height) / 2;
echo "The area of a triangle with base as $base and height as $height is $area";
total answers (1)
start bookmarking useful questions and collections and save it into your
own study-lists, login now to start creating your own collections.