Wednesday, October 16, 2019

121. Qbasic program to display all even numbers from 2 to 100 also display its sum.

121. Write a sub program to display all even numbers from 2 to 100 also display its sum.

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

No comments:

Post a Comment