QBasic Programming

Display cube root of an input number

REM PROGRAM TO DISPLAY CUBE ROOT OF AN INPUT NUMBER
CLS
INPUT “ENTER ANY NUMBER”; N
C = N ^ (1 / 3)
PRINT “CUBE ROOT OF NUMBER ”; C
END

USING SUB PROCEDURE

DECLARE SUB CBROOT (N)
CLS
INPUT “ENTER ANY NUMBER”; N
CALL CBROOT(N)
END

SUB CBROOT (N)
C = N ^ (1 / 3)
PRINT “CUBE ROOT OF NUMBER “; C
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION CBROOT (N)
CLS
INPUT “ENTER ANY NUMBER”; N
C = CBROOT(N)
PRINT “CUBE ROOT OF NUMBER “; C
END

FUNCTION CBROOT (N)
CB= N ^ (1 / 3)
CBROOT = CB
END FUNCTION

Display square root of an input number (Prev Lesson)
(Next Lesson) Display sum of square of any two input numbers
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!