Wednesday, October 16, 2019

63. Qbasic program to input number and find sum of even digits


63.      Write a sub program to input number and find sum of even digits.

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

No comments:

Post a Comment