Qbasic program to find/print sum of all odd numbers from 1 to 100
CLS
FOR I = 1 TO 100 STEP 2
S = S + I
NEXT I
PRINT “SUM OF ALL ODD NUMBERS FROM 1 TO 100=”; S
END
USING SUB
DECLARE SUB ODDDIGITS()
CLS
CALL ODDDIGITS
END
SUB ODDDIGITS
FOR I = 1 TO 100 STEP 2
S = S + I
NEXT I
PRINT “SUM OF ALL ODD NUMBERS FROM 1 TO 100=”; S
END SUB
0 Comments