Var
A,S:integer;
Begin
Write('A = ');ReadLn(A);
While A<>0 do
Begin
S:=S + A mod 10;
A:=A div 10;
End;
WriteLn('S = ',S/4)
End.
Ну или так:
Var
A,S:integer;
Begin
Write('A = ');Read(A);
S:=S + A mod 10;
S:=S + (A div 10) mod 10;
S:=S + (A div 100) mod 10;
S:=S + A div 1000;
Write('S = ',S/4)