QBASIC PROGRAM TO FIND FACTORS OF A NUMBER
INPUT : 16 OUTPUT : 1,2,4,8,16
CLS
INPUT "ENTER ANY NUMBER"; N
PRINT "FACTORS OF"; N; "=";
FOR I = 1 TO N
IF N MOD I = 0 THEN PRINT I;
NEXT I
END
USING SUB
DECLARE SUB FACTORS(N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL FACTORS(N)
END
SUB FACTORS(N)
PRINT "FACTORS OF"; N; "=";
FOR I = 1 TO N
IF N MOD I = 0 THEN PRINT I;
NEXT I
END SUB
0 Comments