Monday, October 11, 2021

QBASIC Program To check the given number is divisible by 4 or not (SUB & FUNCTION Procedure)

CLS
INPUT "Enter a number"; n
x = n MOD 4
IF x = 0 THEN
     PRINT "The given number is exactly divisible by 4";
ELSE
     PRINT "The given number is not exactly divisible by 4";
END IF
END


Using SUB Procedure

DECLARE SUB check(n)
CLS
INPUT "Enter a number"; n
CALL check(n)
END

SUB check (n)
x = n MOD 4
IF x = 0 THEN
     PRINT "The given number is exactly divisible by 4";
ELSE
     PRINT "The given number is not exactly divisible by 4";
END IF
END SUB


Using FUNCTION Procedure

DECLARE FUNCTION check$ (n)
CLS
INPUT "Enter a number"; n
a$ = check$(n)
PRINT a$
END

FUNCTION check$ (n)
x = n MOD 4
IF x = 0 THEN
     ans$ = "The given number is exactly divisible by 4"
ELSE
     ans$ = "The given number is not exactly divisible by 4"
END IF
check$ = ans$
END FUNCTION

No comments:

Post a Comment

If you have any doubts, Please let me know.

[Download PDF] Computer Science Book Gread-10 in Nepali Language

 If you are searching for class 10 Computer Science in Nepali pdf for free download then you are at the right page. This book is soley publi...