WAP to find sum of cube of digits of a number

Qbasic program to find sum of cube of digits of a number



 CLS
 INPUT "ENTER ANY NUMBER"; N
 S = 0
 WHILE N < > 0
 R = N MOD 10
 S = S + R ^ 3
 N = N  10
 WEND
 PRINT "SUM OF CUBE OF DIGITS"; S
 END

USING SUB


DECLARE SUB CUBE(N)
 CLS
 INPUT "ENTER ANY NUMBER"; N
 CALL CUBE(N)
 END
 
 SUB CUBE(N)
 S = 0
 WHILE N < > 0
 R = N MOD 10
 S = S + R ^ 3
 N = N  10
 WEND
 PRINT "SUM OF CUBE OF DIGITS"; S
 END SUB

Post a Comment

0 Comments