Monday, October 11, 2021

Program to print square & cube of an input number (QBASIC)

Program to print Square Number of Given Number.

CLS
INPUT "Enter any number : "; n
s = n ^ 2
PRINT "Square = "; s
END


Using SUB Procedure

DECLARE SUB square(n)
CLS
INPUT "Enter any number : "; n
CALL square(n)
END

SUB square (n)
s = n ^ 2
PRINT "Square = "; s
END SUB


Using FUNCTION Procedure

DECLARE FUNCTION square(n)
CLS
INPUT "Enter any number : "; n
s = square(n)
END

FUNCTION square (n)
s = n ^ 2
PRINT "Square = "; s
END FUNCTION


Program to print Cube Number of Given Number.

CLS
INPUT "Enter any number : "; n
s = n ^ 3
PRINT "Cube = "; s
END


Using SUB Procedure

DECLARE SUB cube(n)
CLS
INPUT "Enter any number : "; n
CALL cube(n)
END

SUB cube(n)
s = n ^ 3
PRINT "Cube = "; s
END SUB


Using FUNCTION Procedure

DECLARE FUNCTION cube(n)
CLS
INPUT "Enter any number : "; n
s = cube(n)
END

FUNCTION cube(n)
s = n ^ 3
PRINT "Cube = "; s
END FUNCTION

No comments:

Post a Comment

If you have any doubts, Please let me know.

[Download PDF] Computer Science Book Gread-10 in Nepali Language

 If you are searching for class 10 Computer Science in Nepali pdf for free download then you are at the right page. This book is soley publi...