QBasic Programming

Display area and perimeter of square

REM PROGRAM TO DISPLAY AREA AND PERIMETER OF SQUARE
CLS
INPUT “ENTER LENGTH”; L
A= L ^ 2
P = 4 * L
PRINT “AREA OF SQUARE “; A
PRINT “PERIMETER OF SQUARE ”; P
END

USING SUB PROCEDURE

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

USING FUNCTION PROCEDURE

DECLARE FUNCTION AREA (L)
DECLARE FUNCTION PERIMETER (L)
CLS
INPUT “ENTER LENGTH”; L
PRINT “AREA OF SQUARE ”; AREA(L)
PRINT “PERIMETER OF RECTANGLE ”; PERIMETER(L)
END

FUNCTION AREA (L)
AREA = L ^ 2
END FUNCTION

FUNCTION PERIMETER (L)
PERIMETER =  4 * L
END FUNCTION

Display area and perimeter of rectangle (Prev Lesson)
(Next Lesson) Display area and circumference of circle
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!