WAP to find sum of odd digits of a number

Qbasic program to find sum 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
 N = N  10
 WEND
 PRINT "SUM OF ODD DIGITS"; S
 END

USING SUB


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

Post a Comment

0 Comments