Wednesday, October 16, 2019

74. Qbasic program to display all prime numbers from 1 to 100


74.      Write a sub program to display all prime numbers from 1 to 100.

DECLARE SUB PRIME ( )
CLS
CALL PRIME
END

SUB PRIME
FOR N = 1 TO 100
C = 0
FOR I = 1 TO N
IF N MOD I = 0 THEN C = C + 1
NEXT I
IF C = 2 THEN PRINT N,
NEXT N
END SUB

No comments:

Post a Comment