Connect Me

twitterfacebookgoogle plus email

  Instagram View Biwas Bhattarai's profile on LinkedIn

WAP using FUNCTION procedure to enter multi-digits number and print the sum of all digits. (Example: 4827, output is 21)

WAP using FUNCTION procedure to enter multi-digits number and print the sum of all digits. (Example: 4827, output is 21)

DECLARE FUNCTION SUM(N)
CLS
INPUT "ENTER A MULTI-DIGITS NUMBER";N
PRINT "SUM OF ALL DIGITS "; SUM(N)
END

FUNCTION SUM(N)
WHILE N<>0
R=N MOD 10
S=S+R
N=N\10
WEND
SUM=S
END FUCTION
Ą
https://www.flickr.com/photos/spklg/15211044551/