QBasic Programming

WAP to display all prime numbers from 1 to 100

CLS

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

USING SUB PROCEDURE

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

WAP to input number and check whether the given no. is prime or composite (Prev Lesson)
(Next Lesson) WAP to display first 15 prime numbers
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!