Qbasic Program to print sum of digits of the given number  

Posted by Mahibabu

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

5 comments

Well it is great. Btw, could u pls tell me how to make a code to sum the number in a string. For example: "1.200abcjjjk2.800nnjk4.500"
The desired output : "8.500"

Thx very much.. .

Will u plz give the program for spy number in qbasic

Nice helpful to me

Great help for me

Thank you for helping me out.

Post a Comment

Contributors

My photo
I am Mahesh Bhandari from Kathmandu, Nepal

Check Nepal's Time