QBASIC PROGRAM TO CALCULATE SUM OF ALL NATURAL NUMBERS FROM 1 TO 100
CLS
FOR I = 1 TO 100
S = S + I
NEXT I
PRINT “SUM OF ALL NATURAL NUMBERS FROM 1 TO 100=”; S
END
USING SUB
DECLARE SUB SUM()
CLS
CALL SUM
END
SUB SUM
FOR I = 1 TO 100
S = S + I
NEXT I
PRINT “SUM OF ALL NATURAL NUMBERS FROM 1 TO 100=”; S
END SUB
0 Comments