QBasic Programming

WAP to input any number and display whether it is odd or even

      REM
      CLS
      INPUT “ENTER ANY NUMBER”; N
      IF N MOD 2 = 0 THEN
      PRINT N; “IS EVEN NUMBER”
ELSE
PRINT N; “IS ODD NUMBER”
END IF
END

DECLARE SUB CHECK (N)
CLS
INPUT “ENTER ANY NUMBER”; N
CALL CHECK (N)
END

SUB CHECK (N)
IF N MOD 2 = 0 THEN
      PRINT N; “IS EVEN NUMBER”
ELSE
PRINT N; “IS ODD NUMBER”
END IF
END SUB

DECLARE FUNCTION CHECK$ (N)
CLS
INPUT “ENTER ANY NUMBER”; N
PRINT N; “IS “; CHECK$(N)
END

FUNCTION CHECK$ (N)
IF N MOD 2 = 0 THEN
CHECK$ = “EVEN NUMBER”
ELSE
CHECK$ = “ODD NUMBER”
END IF
END

WAP to input a year and display whether that year is a leap year or not. [divisible by 4 but not 100] (Prev Lesson)
(Next Lesson) To divide a number by another number and find the quotient and remainder
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!