QBASIC PROGRAM TO FIND CIRCUMFERENCE OF A CIRCLE
Solution :
To find the circumference of a circle in Qbasic we will use the formula C = 2*3.14*R. Here C is where the output is stored and R is the radius of the circle we will enter.
Here we will use Sub and Function Procedure to find the circumference of the circle using QBasic programming.
Display circumference of a circle.
REM PROGRAM TO DISPLAY CIRCUMFERENCE OF CIRCLE
CLS
INPUT “ENTER RADIUS”; R
C = 2 * 3.14 * R
PRINT “CIRCUMFERENCE OF CIRCLE ”; A
END
CIRCUMFERENCE OF A CIRCLE 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
CIRCUMFERENCE OF A CIRCLE 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
thank you for the example of sub procedure and function procedure
ReplyDelete