QBasic Programming

WAP to input any number and display the prime factors

CLS
INPUT "ENTER ANY NUMBER"; N
PRINT "PRIME FACTORS OF"; N; "=";
FOR I = 1 TO N
C = 0
FOR J = 1 TO I
IF I MOD J = 0 THEN C = C + 1
NEXT J
IF N MOD I = 0 AND C = 2 THEN PRINT I;
NEXT I
END

USING SUB PROCEDURE

DECLARE SUB FACT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL FACT (N)
END

SUB FACT (N)
PRINT "PRIME FACTORS OF"; N; "=";
FOR I = 1 TO N
C = 0
FOR J = 1 TO I
IF I MOD J = 0 THEN C = C + 1
NEXT J
IF N MOD I = 0 AND C = 2 THEN PRINT I;
NEXT I
END SUB

WAP to input any number and display the factors (Prev Lesson)
(Next Lesson) WAP to input any number and find sum of factors
Back to QBasic Programming
Notice: compact(): Undefined variable: limits in /home/bhimgautam34/public_html/wp-includes/class-wp-comment-query.php on line 853

Notice: compact(): Undefined variable: groupby in /home/bhimgautam34/public_html/wp-includes/class-wp-comment-query.php on line 853

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!