QBASIC program to print whether the given number is Prime or Composite.

CLS
INPUT "Enter any Number "; n
FOR i = 1 TO n
    IF n MOD i = 0 THEN c = c + 1
NEXT i
IF c = 2 THEN
    PRINT "Prime Number"
ELSE
    PRINT "Composite Number"
END IF
END

By Using SUB ... END SUB
DECLARE SUB Prime(n)
CLS
INPUT "Enter any number : "; n
CALL Prime(n)
END

SUB Prime (n)
    FOR i = 1 TO n
        IF n MOD i = 0 THEN c = c + 1
    NEXT i
    IF c = 2 THEN
        PRINT "Prime Number"
    ELSE
        PRINT "Composite Number"
    END IF
END SUB
By Using FUNCTION ... END FUNCTION
DECLARE FUNCTION Prime(n)
CLS
INPUT "Enter any number : "; n
r = Prime(n)
IF r = 2 THEN
    PRINT "Prime Number"
ELSE
    PRINT "Composite Number"
END IF
END

FUNCTION Prime (n)
    FOR i = 1 TO n
        IF n MOD i = 0 THEN c = c + 1
    NEXT i
    Prime = c
END SUB


Video Tutorial in Nepali Language


 Visit YouTube Channel : Technical School