1. Program to print Square Root of Given Number.
CLS
INPUT "Enter any Number : "; n
sr = n ^ (1 / 2)
PRINT "Square Root = "; sr
END
INPUT "Enter any Number : "; n
sr = n ^ (1 / 2)
PRINT "Square Root = "; sr
END
Using SUB Procedure
DECLARE SUB sqrRoot(n)
CLS
INPUT "Enter any Number : "; n
CALL sqrRoot(n)
END
SUB sqrRoot (n)
sr = n ^ (1 / 2)
PRINT "Square Root = "; sr
END SUB
CLS
INPUT "Enter any Number : "; n
CALL sqrRoot(n)
END
SUB sqrRoot (n)
sr = n ^ (1 / 2)
PRINT "Square Root = "; sr
END SUB
Using FUNCTION Procedure
DECLARE FUNCTION sqrRoot(n)
CLS
INPUT "Enter any Number : "; n
sr = sqrRoot(n)
PRINT "Square Root = "; sr
END
FUNCTION sqrRoot (n)
r = n ^ (1 / 2)
sqrRoot = r
END FUNCTION
INPUT "Enter any Number : "; n
sr = sqrRoot(n)
PRINT "Square Root = "; sr
END
FUNCTION sqrRoot (n)
r = n ^ (1 / 2)
sqrRoot = r
END FUNCTION
2. Program to print Cube Root of Given Number.
CLS
INPUT "Enter any Number : "; n
cr = n ^ (1 / 3)
PRINT "Cube Root = "; cr
END
INPUT "Enter any Number : "; n
cr = n ^ (1 / 3)
PRINT "Cube Root = "; cr
END
Using SUB Procedure
DECLARE SUB cubeRoot(n)
CLS
INPUT "Enter any Number : "; n
CALL cubeRoot(n)
END
SUB cubeRoot (n)
cr = n ^ (1 / 3)
PRINT "Cube Root = "; cr
END SUB
CLS
INPUT "Enter any Number : "; n
CALL cubeRoot(n)
END
SUB cubeRoot (n)
cr = n ^ (1 / 3)
PRINT "Cube Root = "; cr
END SUB
Using FUNCTION Procedure
DECLARE FUNCTION cubeRoot(n)
CLS
INPUT "Enter any Number : "; n
cr = cubeRoot(n)
PRINT "Cube Root = "; cr
END
FUNCTION cubeRoot (n)
r = n ^ (1 / 3)
cubeRoot = r
END FUNCTION
CLS
INPUT "Enter any Number : "; n
cr = cubeRoot(n)
PRINT "Cube Root = "; cr
END
FUNCTION cubeRoot (n)
r = n ^ (1 / 3)
cubeRoot = r
END FUNCTION
No comments:
Post a Comment
If you have any doubts, Please let me know.