(Source Code) Foxpro - Function for finding Sum of Digits

Foxpro/VFP Source Codes

Foxpro - Function for finding Sum of Digits


 Q : Foxpro -  Function for finding Sum of Digits

Solution:-

function sumdigit

para num

sum=0

num=alltrim(str(num))

 

lgt=len(num)

i=1

do while i <= lgt

            s=substr(num,i,1)

            sum=sum+val(s)

            i=i+1

enddo

return sum



comments powered by Disqus