QBASIC PROGRAM TO FIND AREA OF A SQUARE USING SUB AND FUNCTION
Solution:
Display area of square.
REM PROGRAM TO DISPLAY AREA OF SQUARE
CLS
INPUT “ENTER LENGTH”; L
A = L ^ 2
PRINT “AREA OF SQUARE ”; A
END
AREA OF A SQUARE USING SUB PROCEDURE
DECLARE SUB AREA (L)
CLS
INPUT “ENTER LENGTH”; L
CALL AREA(L)
END
SUB AREA (L)
A = L ^ 2
PRINT “AREA OF SQUARE”; A
END SUB
AREA OF A SQUARE USING FUNCTION PROCEDURE
DECLARE FUNCTION AREA (L)
CLS
INPUT “ENTER LENGTH”; L
AR = AREA(L)
PRINT “AREA OF SQUARE ”; AR
END
FUNCTION AREA (L)
A = L ^ 2
AREA = A
END FUNCTION
wap to display square of 7 using sub procedure
ReplyDelete