QBASIC PROGRAM TO FIND PERIMETER OF A SQUARE USING SUB AND FUNCTION
Solution
Display perimeter of a square.
REM PROGRAM TO DISPLAY PERIMETER OF SQUARE
CLS
INPUT “ENTER LENGTH”; L
P = 4 * L
PRINT “PERIMETER OF SQUARE ”; P
END
FIND PERIMETER OF A SQUARE USING SUB PROCEDURE
DECLARE SUB PERIMETER (L)
CLS
INPUT “ENTER LENGTH”; L
CALL PERIMETER (L)
END
SUB PERIMETER (L)
P = 4 * L
PRINT “PERIMETER OF SQUARE”; P
END SUB
FIND PERIMETER OF A SQUARE USING FUNCTION PROCEDURE
DECLARE FUNCTION PERIMETER (L)
CLS
INPUT “ENTER LENGTH”; L
PR = PERIMETER (L)
PRINT “PERIMETER OF SQUARE ”; PR
END
FUNCTION PERIMETER (L)
P = 4 * L
PERIMETER = P
END FUNCTION