QBasic Programming

Display area of triangle when three sides are given

REM PROGRAM TO DISPLAY AREA OF TRIANGLE WHEN THREE SIDES ARE GIVEN
CLS
INPUT “ENTER VALUE FOR FIRST SIDE ”; A
INPUT “ENTER VALUE FOR SECOND SIDE ”; B
INPUT “ENTER VALUE FOR THIRD SIDE ”; C
S = (A + B + C) / 2
AR = (S * (S – A) * (S – B) * (S – C)) ^ (1 / 2)
PRINT “AREA OF TRIANGLE “; AR
END

USING SUB PROCEDURE

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

USING FUNCTION PROCEDURE

DECLARE FUNCTION 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
PRINT “AREA OF TRIANGLE ”; AREA(A, B, C)
END

FUNCTION AREA (A, B, C)
S = (A + B + C) / 2
AR = (S * (S – A) * (S – B) * (S – C)) ^ (1 / 2)
AREA = AR
END FUNCTION

Display area of parallelogram (Prev Lesson)
(Next Lesson) Display total surface area of sphere
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!