Sunday, February 23, 2014

Program in QBASIC to print Sum of the Digits

REM Program to print sum of the digits of a given number
CLS
INPUT "Enter any digit"; n
WHILE n <> 0
r = n MOD 10
s = s + r
n = n \ 10
WEND
PRINT "Sum of digits is "; s
END


0 comments:

Post a Comment