Wednesday, October 16, 2019

20. Qbasic Program to calculate the area of triangle using sides

20.      Write a program to calculate the area of triangle by using SUB…..END SUB.

DECLARE SUB AREA (A, B, C)
CLS
INPUT “ENTER VALUE FOR FIRST SIDE ”; A
INPUT “ENTER VALUE FOR SECOND SIDE ”; B
INPUT “ENTER VALUE FOR THIRD SIDE ”; C
CALL AREA (A, B, C)
END

SUB AREA (A, B, C)
S = (A + B + C) / 2
AR = (S * (S – A) * (S – B) * (S – C)) ^ (1 / 2)
PRINT “AREA OF TRIANGLE”; AR
END SUB

2 comments: