QBasic Programming

WAP to input any number and check whether the given no. is positive or negative

REM
CLS
INPUT “ENTER ANY NUMBER”; N
IF N > 0 THEN
PRINT N; IS POSITIVE NUMBER”
ELSEIF N < 0 THEN
PRINT N; IS NEGATIVE NUMBER”
END IF
END

USING SUB PROCEDURE

DECLARE SUB CHECK (N)
CLS
INPUT “ENTER ANY NUMBER”; N
CALL CHECK (N)
END
SUB CHECK (N)
IF N > 0 THEN
PRINT N; "IS POSITIVE NUMBER”
ELSEIF N < 0 THEN
PRINT N; "IS NEGATIVE NUMBER”
END IF
END SUB

USING FUNCTION PROCEDURE
DECLARE FUNCTION CHECK$ (N)
CLS
INPUT “ENTER ANY NUMBER”; N
PRINT N; “IS “; CHECK$(N)
END
FUNCTION CHECK$ (N)
IF N > 0 THEN
CHECK$ = “POSITIVE NUMBER”
ELSEIF N < 0 THEN
CHECK$ = “NEGATIVE NUMBER”
END IF
END FUNCTION

To divide a number by another number and find the quotient and remainder (Prev Lesson)
(Next Lesson) Input a mark in a subject of a student and check if the student is pass or nor. [Pass Mark >=40]
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!