QBASIC PROGRAM TO FIND SUM OF ODD NUMBERS FROM 10 USER-INPUTED NUMBERS
CLS
DIM N(10)
FOR I = 1 TO 10
INPUT "ENTER THE NUMBERS"; N(I)
IF N(I) MOD 2 = 1 THEN S = S + N(I)
NEXT I
PRINT "SUM OF 10 ODD NUMBERS"; S
END
USING SUB
DECLARE SUB ODD()
CLS
CALL ODD
END
SUB ODD
DIM N(10)
FOR I = 1 TO 10
INPUT "ENTER THE NUMBERS"; N(I)
IF N(I) MOD 2 = 1 THEN S = S + N(I)
NEXT I
PRINT "SUM OF 10 ODD NUMBERS"; S
END SUB
0 Comments