Saturday, October 22, 2016

Qbasic Program: Area of Rectangle



18. Display area of rectangle.

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






19. 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

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










20. Display area of circle.

REM PROGRAM TO DISPLAY AREA OF CIRCLE
CLS
INPUT “ENTER RADIUS”; R
A = 3.14 * R ^ 2
PRINT “AREA OF CIRCLE ”; A
END

USING SUB PROCEDURE

DECLARE SUB AREA (R)
CLS
INPUT “ENTER RADIUS”; R
CALL AREA(R)
END

SUB AREA (R)
A = 3.14 * R ^ 2
PRINT “AREA OF CIRCLE ”; A
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION AREA (R)
CLS
INPUT “ENTER RADIUS”; R
AR = AREA(R)
PRINT “AREA OF CIRCLE ”; AR
END

FUNCTION AREA (L, B)
A = 3.14 * R ^ 2
AREA = A
END FUNCTION










21. Display perimeter of rectangle.

REM PROGRAM TO DISPLAY PERIMETER OF RECTANGLE
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
P = 2 * (L + B)
PRINT “PERIMETER OF RECTANGLE ”; P
END

USING SUB PROCEDURE

DECLARE SUB PERIMETER (L, B)
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
CALL PERIMETER(L, B)
END

SUB PERIMETER (L, B)
P = 2 * (L + B)
PRINT “PERIMETER OF RECTANGLE ”; P
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION PERIMETER (L, B)
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
PR = PERIMETER(L, B)
PRINT “PERIMETER OF RECTANGLE ”; PR
END

FUNCTION PERIMETER (L, B)
P = 2 * (L + B)
PERIMETER = P
END FUNCTION






22. Display perimeter of square.

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

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

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









23. Display circumference of circle.

REM PROGRAM TO DISPLAY CIRCUMFERENCE OF CIRCLE
CLS
INPUT “ENTER RADIUS”; R
C = 2 * 3.14 * R
PRINT “CIRCUMFERENCE OF CIRCLE ”; A
END

USING SUB PROCEDURE

DECLARE SUB CIRCUM (R)
CLS
INPUT “ENTER RADIUS”; R
CALL CIRCUM (R)
END

SUB CIRCUM (R)
C = 2 * 3.14 * R
PRINT “CIRCUMFERENCE OF CIRCLE ”; C
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION CIRCUM (R)
CLS
INPUT “ENTER RADIUS”; R
CR = CIRCUM(R)
PRINT “CIRCUMFERENCE OF CIRCLE ”; CR
END

FUNCTION CIRCUMFERENCE (L, B)
C = 2 * 3.14 * R
CIRCUM  = C
END FUNCTION









24. Display area and perimeter of rectangle.

REM PROGRAM TO DISPLAY AREA AND PERIMETER OF RECTANGLE
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
A= L * B
P = 2 * (L + B)
PRINT “AREA OF RECTANGLE “; A
PRINT “PERIMETER OF RECTANGLE ”; P
END

USING SUB PROCEDURE

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

SUB AREA (L, B)
A = L * B
PRINT “AREA OF RECTANGLE ”; A
END SUB

SUB PERIMETER (L, B)
P = 2 * (L + B)
PRINT “PERIMETER OF RECTANGLE ”; P
END SUB


USING FUNCTION PROCEDURE

DECLARE FUNCTION AREA (L, B)
DECLARE FUNCTION PERIMETER (L, B)
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
AR = AREA(L, B)
PR = PERIMETER(L, B)
PRINT “AREA OF RECTANGLE”; AR
PRINT “PERIMETER OF RECTANGLE ”; PR
END

FUNCTION AREA (L, B)
A = L * B
AREA = A
END FUNCTION


FUNCTION PERIMETER (L, B)
P = 2 * (L + B)
PERIMETER = P
END FUNCTION

25. 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

26. Display area and circumference of circle.

REM PROGRAM TO DISPLAY AREA AND CIRCUMFERENCE OF CIRCLE.
CLS
INPUT “ENTER RADIUS ”; R
A= 3.14 * R ^ 2
C = 2 * 3.14 * R
PRINT “AREA OF CIRCLE “; A
PRINT “CIRCUMFERENCE OF CIRCLE ”; C
END

USING SUB PROCEDURE

DECLARE SUB AREA (R)
DECLARE SUB CIRCUM (R)
CLS
INPUT “ENTER RADIUS”; R
CALL AREA(R)
CALL CIRCUM(R)
END

SUB AREA (R)

A= 3.14 * R ^ 2
PRINT “AREA OF CIRCLE”; A
END SUB

SUB CIRCUM (R)
C = 2 * 3.14 * R
PRINT “CIRCUMFERENCE OF CIRCLE”; C
END SUB


USING FUNCTION PROCEDURE

DECLARE FUNCTION AREA (R)
DECLARE FUNCTION CIRCUM (R)
CLS
INPUT “ENTER RADIUS”; R
PRINT “AREA OF SQUARE ”; AREA(R)
PRINT “CIRCLE OF CIRCUMFERENCE”; CIRCUM (R)
END

FUNCTION AREA (R)
AREA = 3.14 * R ^ 2
END FUNCTION

FUNCTION CIRCUM (R)
CIRCUM = 2 * 3.14 * R
END FUNCTION

No comments:

Post a Comment