write a program in QBasic to calculate area and perimeter of a rectangle,circle and square.
(any one to can do)
Answers
(a) For circle =
Area of circle = pie r^2
Perimeter of circle = 2 pie r
(b) For rectangle =
Area of rectangle = length ×breadth
Perimeter = sum of all sides
(c) For square=
Area of square = side ^2
Perimeter = sum of all sides.
"REM PROGRAM TO DISPLAY AREA OF RECTANGLE
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
A = L * B
PRINT “AREA OF RECTANGLE ”; A
END
USING SUB PROCEDURE
DECLARE SUB AREA (L, B)
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
CALL AREA(L, B)
END
SUB AREA (L, B)
A = L * B
PRINT “AREA OF RECTANGLE ”; A
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION AREA (L, B)
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
AR = AREA(L, B)
PRINT “AREA OF RECTANGLE ”; AR
END
FUNCTION AREA (L, B)
A = L * B
AREA = A
END FUNCTION
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
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
"