Wednesday, October 16, 2019

16. Qbasic program to find the area and perimeter of square


16.      Write a program using SUB……END SUB to find the area and perimeter of square. [P=4L] [A=L2]

DECLARE SUB AREA (L)
DECLARE SUB PERIMETER (L)
CLS
INPUT “ENTER LENGTH”; L
CALL AREA (L)
CALL PERIMETER (L)
END

SUB AREA (L)
A = L ^ 2
PRINT “AREA OF SQUARE”; A
END SUB

SUB PERIMETER (L)
P = 4 * L
PRINT “PERIMETER OF SQUARE”; P
END SUB

No comments:

Post a Comment