QBASIC PROGRAM TO CALCULATE SUM OF SQUARE OF N NUMBERS

QBASIC PROGRAM TO CALCULATE SUM OF SQUARE OF N NUMBERS


5 = 55, 100 = 338350, etc.


 CLS
 INPUT “ENTER THE NUMBER”; N
 S = N * (N + 1) * (2 * N + 1) / 6
 PRINT “SUM OF SQUARE OF ”; N; “NUMBERS=”; S
 END

USING SUB


DECLARE SUB SUMSQUARE(N)
 CLS
 INPUT “ENTER THE NUMBER”; N
 CALL SUMSQUARE(N)
 END
 
 SUB SUMSQUARE(N)
 S = N * (N + 1) * (2 * N + 1) / 6
 PRINT “SUM OF SQUARE OF ”; N; “NUMBERS=”; S
 END SUB

Post a Comment

0 Comments