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
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
Using SUB Procedure
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
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
Using FUNCTION Procedure
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 FUNCTION
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 FUNCTION
No comments:
Post a Comment
If you have any doubts, Please let me know.