WAP to find sum of all numbers from 2 to 50

Qbasic program to find sum of all numbers from 2 to 50



CLS
 FOR I = 2 TO 50
 S = S + I
 NEXT I
 PRINT “SUM OF NUMBERS BETWEEN 2 TO 50” ; S
 END

USING SUB


DECLARE SUB SUM()
 CLS
 CALL SUM
 END
 
 SUB SUM
 FOR I = 2 TO 50
 S = S + I
 NEXT I
 PRINT “SUM OF NUMBERS BETWEEN 2 TO 50” ; S
 END SUB

Post a Comment

0 Comments