Computer Notes, Programming codes, Hardware and Networking Tip, Entertainment, Biography, Internet Tip, Tech News, Latest Technology, YouTube,

Prime or Composite Number in QBASIC Programming

Prime or composite number, Prime or Composite number in qbasic, qbasc program to print whether the given number is prime or composite,

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


Post a Comment

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget