Enter digits -> Addition of the digits would be displayed

//Enter the digits ..
//Addition of the digits would be displayed

n=input("Enter digits to be added: ")
s=0
while(n>0)
    r=modulo(n,10)
    s=s+r
    n=int(n/10)
end
disp(s,"Sum of digits is:")

Output
-->exec('D:\Scilab prog by me\prac4.sce', -1)
Enter digits to be added: 1234

 Sum of digits is:  

    10.

No comments:

Post a Comment