QBasic Programming

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

CLS
INPUT “ENTER ANY NUMBER”; N
IF N > 0 THEN
PRINT N; "IS POSITIVE NUMBER”
ELSEIF N < 0 THEN
PRINT N; "IS NEGATIVE NUMBER”
ELSE
PRINT N; "IS ZERO”
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”
ELSE
PRINT N; "IS ZERO”
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”
ELSE
CHECK$ = “ZERO”
END IF : END FUNCTION

WAP to input any number and check whether the given no. is divisible by 3 and 7 or not (Prev Lesson)
(Next Lesson) WAP to input a year and display whether that year is a leap year or not. [divisible by 4 but not 100]
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!