Wednesday, October 16, 2019

47. Qbasic program to define a function procedure which returns whether a input number is positive, negative or zero using SGN function


47.      Write a program to define a function procedure which returns whether a input number is positive, negative or zero using SGN function.

DECLARE FUNCTION CHECK$ (N)
CLS
INPUT "Enter any number"; N
PRINT "The given number is "; CHECK$(N)
END
FUNCTION CHECK$ (N)
S = SGN(N)
SELECT CASE S
    CASE 1
        CHECK$ = "positive number"
    CASE -1
        CHECK$ = "negative number"
    CASE 0
        CHECK$ = "zero"
END SELECT
END FUNCTION

No comments:

Post a Comment