QBASIC – Area of a triangle

Below is the QBASIC program to calculate the area of a triangle.

REM Program to find area of triangle
CLS
INPUT "Enter the base of triangle: "; b
INPUT "Enter the height: "; h
area = 1/2 * b * h
PRINT "Area of triangle is: ";area
END

Explanation:

Let’s first see the formula: Area = 1/2 * b * h. So, we can determine the area of the triangle by taking the base and height of the triangle from the user and multiplying the product of base and height by 1/2 (half).

NOTE: Here b is not the breadth but is the base of the triangle.

Leave a Comment

Your email address will not be published. Required fields are marked *

Exit mobile version