program hotrotinhoc;
var n: byte;
s: integer;
begin
write('n='); readln(n);
s:=0;
while n<>0 do
begin
s:=s+(n mod 10);
n:=n div 10;
end;
write(s);
readln
end.
Quá dễ
uses crt;
var n,i,d,t,x,y:integer;
st:string;
begin
clrscr;
write('n='); readln(n);
str(n,st);
t:=0;
d:=length(st);
for i:=1 to d do
begin
val(st[i],x,y);
t:=t+x;
end;
writeln('tong cac chu so cua ',n,' la: ',t);
readln;
end.
Program Tinh_tong;
uses crt;
var a,b,tong: integer;
Begin
Write('Nhap so thu nhat:'); Readln(a);
Write('Nhap so thu hai:'); Readln(b);
tong:=a+b;
Writeln('Tong hai so la:',tong);
Readln
End.