# QBasic Programming

## WAP to input any number and find sum of factors

CLS
INPUT "ENTER ANY NUMBER"; N
S = 0
FOR I = 1 TO N
IF N MOD I = 0 THEN S = S + I
NEXT I
PRINT "SUM OF FACTORS="; S
END
USING SUB PROCEDURE

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

SUB FACT (N)
S = 0
FOR I = 1 TO N
IF N MOD I = 0 THEN S = S + I
NEXT I
PRINT "SUM OF FACTORS="; S
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION FACT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
PRINT "SUM OF FACTORS=";  FACT (N)
END

FUNCTION FACT (N)
S = 0
FOR I = 1 TO N
IF N MOD I = 0 THEN S = S + I
NEXT I
FACT = S
END FUNCTION