QBASIC program to check whether the input number is positive, negative, or neutral.
CLS
INPUT "Enter any
number"; num
IF num > 0 THEN
PRINT num; "is positive
number"
ELSEIF num < 0 THEN
PRINT num; "is negative
number"
ELSE
PRINT num; "is neutral
number"
END IF
END
By using SUB procedure (SUB…END
SUB)
DECLARE SUB check (num)
CLS
INPUT "Enter any
number"; num
CALL check(num)
END
SUB check (num)
IF num > 0 THEN
PRINT num; "is positive
number"
ELSEIF num < 0 THEN
PRINT num; "is negative
number"
ELSE
PRINT num; "is neutral
number"
END IF
END SUB
By using FUNCTION procedure
(FUNCTION…..END FUNCTION)
DECLARE FUNCTION check$ (no)
CLS
INPUT "Enter any
number"; no
PRINT no; check$(no)
END
FUNCTION check$ (no)
IF no > 0 THEN
check$ = "is Positive
number"
ELSEIF no < 0 THEN
check$ = "is Negative
number"
ELSE
check$ = "is Neutral number"
END IF
END FUNCTION
Output:
No comments:
Post a Comment