Computer for SEE and NEB

It is a complete SEE and NEB solution for computer science. It includes Computer Fundamentals, Database (SQL), Programming in C QBASIC, CSS, JavaScript, and PHP for beginners.

Breaking

Post Top Ad

Your Ad Spot

Wednesday, November 30, 2022

QBASIC program to check whether the input number is positive, negative, or neutral.

 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

Post Top Ad

Your Ad Spot

Pages