Uses crt;
Var
n,t:longint;
BEGIN
Read(n);
While n<>0 do
Begin
t:=t+n mod 10;
n:=n div 10;
End;
Write(t);
Readln;
END.
Refer:
Program baitap;
Uses crt;
Var n,x,T:integer;
Begin
Clrscr;
T:=0;
Write('n='); Readln(n);
While ( N <> 0 ) do
Begin
x := n mod 10;
n := n div 10;
T := T + x;
End;
Writeln('T=',T);
Readln
End.