QBASIC PROGRAM TO FIND SUM OF CUBE OF ODD DIGITS OF A NUMBER

QBASIC PROGRAM TO FIND SUM OF CUBE OF ODD DIGITS OF A NUMBER



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

USING SUB


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

Post a Comment

0 Comments