WAP to print all even numbers from 1 to 100 and find their sum

Qbasic program to print all even numbers from 1 to 100 and find their sum



CLS
 FOR I = 2 TO 100 STEP 2
 PRINT I,
 S = S + I
 NEXT I
 PRINT “SUM OF ALL EVEN NUMBERS FROM 1 TO 100=”; S
 END

USING SUB


DECLARE SUB EVEN()
 CLS
 CALL EVEN
 END
 
 SUB EVEN
 FOR I = 2 TO 100 STEP 2
 PRINT I,
 S = S + I
 NEXT I
 PRINT “SUM OF ALL EVEN NUMBERS FROM 1 TO 100=”; S
 END SUB

Post a Comment

0 Comments