Wednesday, October 13, 2021

QBASIC Program to calculate the area of triangle when three sides are given

CLS
INPUT "Enter the value of first side : "; x
INPUT "Enter the value of second side : "; y
INPUT "Enter the value of third side : "; z
s = (x + y + z) / 2
a = (s * (s - a) * (s - b) * (s - c)) ^ (1 / 2)
PRINT "Area of triangle is : "; a
END


Area of triangle when 3 sides are given using SUB Procedure

DECLARE SUB area(x,y,z)
CLS
INPUT "Enter the value of first side : "; x
INPUT "Enter the value of second side : "; y
INPUT "Enter the value of third side : "; z
CALL area(x, y, z)
END

SUB area (x, y, z)
s = (x + y + z) / 2
a = (s * (s - a) * (s - b) * (s - c)) ^ (1 / 2)
PRINT "Area of triangle is : "; a
END SUB

Area of triangle when 3 sides are given using FUNCTION Procedure

DECLARE FUNCTION area(x,y,z)
CLS
INPUT "Enter the value of first side : "; x
INPUT "Enter the value of second side : "; y
INPUT "Enter the value of third side : "; z
a = area(x, y, z)
PRINT "Area of triangle is : "; a
END

FUNCTION area (x, y, z)
s = (x + y + z) / 2
a = (s * (s - a) * (s - b) * (s - c)) ^ (1 / 2)
area = a
END FUNCTION

No comments:

Post a Comment

If you have any doubts, Please let me know.

[Download PDF] Computer Science Book Gread-10 in Nepali Language

 If you are searching for class 10 Computer Science in Nepali pdf for free download then you are at the right page. This book is soley publi...