Saturday, October 22, 2016

Qbasic Program: Area of four walls



27. Display area of 4 walls.

REM PROGRAM TO DISPLAY AREA OF 4 WALLS
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
INPUT “ENTER HEIGHT”; H
A = 2 * H * (L + B)
PRINT “AREA OF FOUR WALLS“; A
END

USING SUB PROCEDURE

DECLARE SUB AREA (L, B, H)
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
INPUT “ENTER HEIGHT”; H
CALL AREA (L, B, H)
END

SUB AREA (L, B, H)
A = 2 * H * (L + B)
PRINT “AREA OF FOUR WALLS”; A
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION AREA (L, B, H)
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
INPUT “ENTER HEIGHT”; H
AR = AREA(L, B, H)
PRINT “AREA OF FOUR WALLS”; AR
END

FUNCTION AREA (L, B, H)
A = 2 * H * (L + B)
AREA = A
END FUNCTION




28. Display area of triangle.

REM PROGRAM TO DISPLAY AREA OF TRIANGLE
CLS
INPUT “ENTER BREADTH”; B
INPUT “ENTER HEIGHT”; H
A = 1 / 2  * (B * H)
PRINT “AREA OF TRIANGLE “; A
END

USING SUB PROCEDURE

DECLARE SUB AREA (B, H)
CLS
INPUT “ENTER BREADTH”; B
INPUT “ENTER HEIGHT”; H
CALL AREA (B, H)
END

SUB AREA (B, H)
A = 1 / 2  * (B * H)
PRINT “AREA OF TRIANGLE”; A
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION AREA (B, H)
CLS
INPUT “ENTER BREADTH”; B
INPUT “ENTER HEIGHT”; H
AR = AREA( B, H)
PRINT “AREA OF TRIANGLE ”; AR
END

FUNCTION AREA (B, H)
A = 1 / 2 * (B * H)
AREA = A
END FUNCTION







29. Display area of parallelogram.

REM PROGRAM TO DISPLAY AREA OF PARALLELOGRAM
CLS
INPUT “ENTER BREADTH”; B
INPUT “ENTER HEIGHT”; H
A = B * H
PRINT “AREA OF PARALLELOGRAM “; A
END

USING SUB PROCEDURE

DECLARE SUB AREA (B, H)
CLS
INPUT “ENTER BREADTH”; B
INPUT “ENTER HEIGHT”; H
CALL AREA (B, H)
END

SUB AREA (B, H)
A = B * H
PRINT “AREA OF PARALLELOGRAM ”; A
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION AREA (B, H)
CLS
INPUT “ENTER BREADTH”; B
INPUT “ENTER HEIGHT”; H
AR = AREA( B, H)
PRINT “AREA OF PARALLELOGRAM ”; AR
END

FUNCTION AREA (B, H)
A = B * H
AREA = A
END FUNCTION






30. 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

No comments:

Post a Comment